need a thread to keep a socket connection alive?
Ben Sizer
kylotan at gmail.com
Mon Apr 24 05:34:21 EDT 2006
nephish at xit.net wrote:
> i have a script that waits for message packets from a data server over
> a socket.
If you're using TCP, bear in mind that you do not receive packets - you
receive a stream of data, which may usually come in the same quantities
as it was sent, but not always. If you don't take that into account,
you may end up missing a valid message because it arrived in several
parts.
> it works fine for a while, but the server requires that i send a
> heartbeat ping every 600 seconds or it will terminate the connection.
It is probably worth just reconnecting if necessary. After all, you
could be disconnected for other reasons too.
--
Ben Sizer
More information about the Python-list
mailing list