Socket communication problem
exarkun at divmod.com
Wed Oct 24 22:01:13 CEST 2007
On Wed, 24 Oct 2007 20:42:49 +0100, Sandy Dunlop <sandy.dunlop at gmail.com> wrote:
>I'm new here, and fairly new to Python. I have been playing around with
>Python and started having a look at socket IO. I have written a script
>that communicates over a network to a server which is written in C.
>While trying to get this working, I have been running into a problem
>where the Python client appears to hang when it should be receiving data
>back from the server.
>After a few successful exchanges of data, the server sends 3605 bytes to
>the client, which the client receives. The server then sends 2 bytes to
>the client, and the client doesn't get them. A client program written in
>C# does not have this problem.
Neither the server nor client Python programs you linked to uses the socket
API correctly. The most obvious mistake is that the code does not check the
return value of socket.send(), which you must do.
Twisted is a third-party library which abstracts many of the low-level
details of the BSD socket API away from you. You might want to take a
look at it.
More information about the Python-list