TCP Socket question

Joshua Muskovitz josh at open.com
Tue Nov 14 21:56:24 EST 2000


> 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.

The rest of the message literally sits in the socket, waiting for you to
read it with another call to recv().  Think of it like taking an empty jug
to your water faucet.  bufsize specifies how big the jug is.  recv will fill
the jug until either (a) the jug is full, or (b) there is no more water
available.

To find out if you got it all, you can do another recv().  But be warned --
if the socket is a blocking socket (this is the default), then recv() will
hang until there is more data to read.  You can solve this by using
select.select() with a timeout.  This will hang until either (a) there is
new data to read, or (b) the timeout expires.

-- josh




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



More information about the Python-list mailing list