Sockets: Sending/receiving arbitrary amounts of data

Daniel Klein danielk at aracnet.com
Sun Apr 29 12:20:45 EDT 2001


Just starting to get my head around sockets and I'm using PP2E by Mark Lutz as
my guide.

The examples all seem to indicate that you need to send/recv a specific
(maximum) amount of data. The examples all use '1024' bytes to send or recv.
Although this can be increased, there is always the possiblility of needing
more.

What if the server doesn't know in advance how much data will be sent from the
client? The server is waiting for '1024' bytes and the client sends down 10k.
Does this mean I have to first send a "here's how much is coming" message to
the server so that the server can receive it in '10' 1k chunks? And likewise if
the server sends more than is expected to the client. I don't mind doing it
this way, I'd just like to know if there is a 'high-level' way to implement
this so that client and server handle the requests regardless of how much data
is being sent/recv'd ?

Thanks in advance for any light you can shed on this,

Daniel Klein
Portland, OR USA





More information about the Python-list mailing list