Re: Python recv loop

2013-02-11 Thread Ihsan Junaidi Ibrahim
On Feb 11, 2013, at 11:24 PM, Chris Angelico wrote: > On Tue, Feb 12, 2013 at 2:11 AM, MRAB wrote: >> I probably wouldn't make it fixed length. I'd have the length in >> decimal followed by, say, "\n". > > Or even "followed by any non-digit". Chances are your JSON data begins > with a non-digi

Re: Python recv loop

2013-02-11 Thread Ihsan Junaidi Ibrahim
Hi MRAB, My code now works thanks to your advice. {"msgver": "1.0", "msgid": "200", "subcode": "100", "appver": "1.0", "appid": "1.0", "data": {"1": "igb0", "2": "igb1", "ifcnt": "2"}} connected to misty:8080 sending data 138 bytes sent: 0x86{"msgver": "1.0", "msgid": "200", "subcode": "100", "

Re: Python recv loop

2013-02-11 Thread Ihsan Junaidi Ibrahim
Hi Dave, On Feb 11, 2013, at 9:22 AM, Dave Angel wrote: > Exactly how are you sending "hexadecimal" ? If that 0xad (which is only one > byte, what about the other 3 ?) is intended to be a C description, then it's > certainly not hex, it's binary. And probably little-endian, to boot. That's

Re: Python recv loop

2013-02-11 Thread Ihsan Junaidi Ibrahim
Hi Roy, On Feb 11, 2013, at 10:24 AM, Roy Smith wrote: > > Is this server that you're talking to something that you have control > over, i.e. are you stuck with this protocol? Given a choice, I'd go > with something like JSON, for which pre-existing libraries for every > language under the s

Python recv loop

2013-02-10 Thread Ihsan Junaidi Ibrahim
Hi, I'm implementing a python client connecting to a C-backend server and am currently stuck to as to how to proceed with receiving variable-length byte stream coming in from the server. I have coded the first 4 bytes (in hexadecimal) of message coming in from the server to specify the length