Read / Write image file REC SEP

phil phillip.watts at anvilcom.com
Wed May 4 12:04:10 EDT 2005


>>
>>So what if the client sends 4 bytes, and then sends 8000 bytes?  WIll I
>>get the first 4 bytes as a separate msg so to speak?  Basically i want
>>to catch each message from the client as a whole.
>>

IF YOU WANT SEPARATE MESSAGES:
Modify the client to send an end of record, then:
On Server:


datasep = '<EOR>'           # or whatever you like
datal = []
seversocket.settimeout(5.0) # or 0(infinite) or something reasonable
while 1:
     try:
         data = serversocket.recv(BUFFERSIZE) # fails on timeout
         if not data: break
         datal.append(data)
     except: break

msglist = datal.split(datasep)   # a list of messages




More information about the Python-list mailing list