TCP Socket question

Rick Lee rwklee at home.com
Tue Nov 14 22:14:29 EST 2000


Let me rephrase my question, now that I have played around with socket a
little bit.

If bufsize is smaller than the size of the message that the sender sends
me, the rest is waiting for me at the next s.recv(bufsize).  My question
is: how do I know this condition has occurred?

I am in a situation where: I don't really know what the maximum message
size the sender can send to me.  And let's say there is no way in the
message itself to tell if the end has been reached.

If I just blindly try a second s.recv(bufsize) if the first received
string length is the same as bufsize, I run the chance that I will be
blocked, if in fact the sender's message size is exactly bufsize.

- Rick Lee

Rick Lee wrote:

> Hi,
>
> I have a question about the s.recv method for a TCP socket:  The syntax
> is:
>
>     s.recv (bufsize [,flags])
>
> And the manual says: "Receives data from the socket.  The data is
> returned as a string.  The maximum amount of data to be received is
> specified by bufsize..."
>
> My question is: what happens if the sender's message is larger than
> bufsize?  Is the rest discarded, or what?  Also, how would I know that
> this condition has occurred?  Note that the flags values don't seem to
> help with this question.
>
> Thanks in advance
>
> - Rick Lee




More information about the Python-list mailing list