Problem Sending Data with SocketServer.ThreadingTCPServer

Peter Hansen peter at engcorp.com
Thu Feb 19 18:56:09 EST 2004


UrgeOverkill wrote:
> 
> I'm having a problem sending data from a socket server.  The server
> side reports that it has sent 4845 bytes but the client reports only
> 1448 bytes received.  The kicker is that this ONLY happens accross the
> internet...  I've tested this with multiple connections.  If I run the
> same server and client, connect them locally I don't have a problem
> with byte totals.  Is there a timeout that I need to set... I've
> looked at and change several SOL_SOCKET parameters (i.e. SO_SNDBUF,
> etc) but this hasn't fixed my problem... This is the last thing I need
> to fix on this and any help would be greatly appreciated...

Example code?

You don't give quite enough info for one to how familiar you are with 
socket programming.  Are you aware, for example, that you have to read
repeatedly from the socket, not just call .recv() once?  (That's a common
rookie mistake.)

What code is generating these reports about bytes sent and received?
Why do you trust the numbers?  Just because a high level call with 4845
bytes went down into the .send routine and returned doesn't mean that
many bytes actually went out the port.

Have you reduced this down to the smallest program you can make which
demonstrates the problem?  Often the problem will go away at some
point as you do that, and then you can quickly home in on the change
which was involved.

-Peter



More information about the Python-list mailing list