Re: How to receive a data file of unknown length using a python socket?

2015-04-22 Thread sandyethadka
On Sunday, 19 July 2009 03:03:48 UTC+5:30, twgray wrote: > I am attempting to send a jpeg image file created on an embedded > device over a wifi socket to a Python client running on a Linux pc > (Ubuntu). All works well, except I don't know, on the pc client side, > what the file size is? The fo

Re: How to receive a data file of unknown length using a python socket?

2009-07-19 Thread python
>> I am interested in seeing your code and would be grateful if you shared it >> with this list. > All right here it is. Hope it helps. Hendrik, Thank you very much!! (I'm not the OP, but found this thread interesting) Best regards, Malcolm -- http://mail.python.org/mailman/listinfo/python-li

Re: How to receive a data file of unknown length using a python socket?

2009-07-19 Thread Hendrik van Rooyen
On Sunday 19 July 2009 15:18:21 pyt...@bdurham.com wrote: > Hi Hendrik, > > If anybody is interested I will attach the code here. It is not a big > > module. > > I am interested in seeing your code and would be grateful if you shared > it with this list. All right here it is. Hope it helps - He

Re: How to receive a data file of unknown length using a python socket?

2009-07-19 Thread python
Hi Hendrik, > I have ended up writing a netstring thingy, that addresses the string > transfer problem by having a start sentinel, a four byte ASCII length (so you > can see it with a packet sniffer/displayer) and the rest of the data escaped > to take out the start sentinel and the escape char

Re: How to receive a data file of unknown length using a python socket?

2009-07-19 Thread Hendrik van Rooyen
On Sunday 19 July 2009 02:12:32 John Machin wrote: > > Apologies in advance for my ignorance -- the last time I dipped my toe > in that kind of water, protocols like zmodem and Kermit were all the > rage -- but I would have thought there would have been an off-the- > shelf library for peer-to-peer

Re: How to receive a data file of unknown length using a python socket?

2009-07-19 Thread Piet van Oostrum
> John Machin (JM) wrote: >JM> On Jul 19, 7:43 am, Irmen de Jong wrote: >>> twgray wrote: >>> > I am attempting to send a jpeg image file created on an embedded >>> > device over a wifi socket to a Python client running on a Linux pc >>> > (Ubuntu).  All works well, except I don't know, on t

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread Aahz
In article , MRAB wrote: > >If you send the length as 4 bytes then you'll have to decide whether >it's big-endian or little-endian. An alternative is to send the length >as characters, terminated by, say, '\n' or chr(0). Alternatively, make it a fixed-length string of bytes, zero-padded in front

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread twgray
On Jul 18, 7:33 pm, MRAB wrote: > Nobody wrote: > > On Sat, 18 Jul 2009 14:33:48 -0700, twgray wrote: > > >> It appears to be locking up in  'data=self.s.recv(MAXPACKETLEN)' on > >> the final packet, which will always be less than MAXPACKETLEN. > > >> I guess my question is, how do I detect end of

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread MRAB
Nobody wrote: On Sat, 18 Jul 2009 14:33:48 -0700, twgray wrote: It appears to be locking up in 'data=self.s.recv(MAXPACKETLEN)' on the final packet, which will always be less than MAXPACKETLEN. I guess my question is, how do I detect end of data on the client side? recv() should return zero

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread John Machin
On Jul 19, 7:43 am, Irmen de Jong wrote: > twgray wrote: > > I am attempting to send a jpeg image file created on an embedded > > device over a wifi socket to a Python client running on a Linux pc > > (Ubuntu).  All works well, except I don't know, on the pc client side, > > what the file size is?

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread Nobody
On Sat, 18 Jul 2009 14:33:48 -0700, twgray wrote: > It appears to be locking up in 'data=self.s.recv(MAXPACKETLEN)' on > the final packet, which will always be less than MAXPACKETLEN. > > I guess my question is, how do I detect end of data on the client side? recv() should return zero when the

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread MRAB
twgray wrote: On Jul 18, 4:43 pm, Irmen de Jong wrote: twgray wrote: I am attempting to send a jpeg image file created on an embedded device over a wifi socket to a Python client running on a Linux pc (Ubuntu). All works well, except I don't know, on the pc client side, what the file size is?

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread John Machin
On Jul 19, 8:04 am, twgray wrote: > send a 4 byte address from the embedded device, how do I convert that, > in Python, to a 4 byte, or long, number? struct.unpack() is your friend. Presuming the embedded device is little-endian, you do: the_int = struct.unpack('http://docs.python.org/library/s

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread twgray
On Jul 18, 4:43 pm, Irmen de Jong wrote: > twgray wrote: > > I am attempting to send a jpeg image file created on an embedded > > device over a wifi socket to a Python client running on a Linux pc > > (Ubuntu).  All works well, except I don't know, on the pc client side, > > what the file size is?

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread Tycho Andersen
On Sat, Jul 18, 2009 at 4:43 PM, Irmen de Jong wrote: > twgray wrote: >> >> I am attempting to send a jpeg image file created on an embedded >> device over a wifi socket to a Python client running on a Linux pc >> (Ubuntu).  All works well, except I don't know, on the pc client side, >> what the fi

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread Irmen de Jong
twgray wrote: I am attempting to send a jpeg image file created on an embedded device over a wifi socket to a Python client running on a Linux pc (Ubuntu). All works well, except I don't know, on the pc client side, what the file size is? You don't. Sockets are just endless streams of bytes.

How to receive a data file of unknown length using a python socket?

2009-07-18 Thread twgray
I am attempting to send a jpeg image file created on an embedded device over a wifi socket to a Python client running on a Linux pc (Ubuntu). All works well, except I don't know, on the pc client side, what the file size is? The following is a snippet: [code] f = open("frame.jpg",mode =