Best way to "flush" incoming socket data?
Robert Oschler
Oschler at earthlink.net
Sun Nov 10 13:29:54 EST 2002
More information about the Python-list mailing list
Sun Nov 10 13:29:54 EST 2002
- Previous message (by thread): wxPython and console window
- Next message (by thread): NEWBIE: Extending Python with C
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I have a simple Python script that connects to various TCP servers that use string commands. Some of them print a banner upon connection some don't. For the ones that send me a banner string upon connect, what's the best way to clear out the banner from the receive queue? Currently I do: # set timeout value using Timothy O' Malley's timeoutsocket module # to something real small. timeoutsocket.SetDefaultSocketTimeout(3) dump_banner = sock.recv(1024) # flush banner if any. # restore default socket timeout to something reasonable timeoutsocket.SetDefaultSocketTimeout(20) However, is there another way to flush the receive buffer so I don't have to waste 3 seconds waiting for a possibly non-existent banner? thx
- Previous message (by thread): wxPython and console window
- Next message (by thread): NEWBIE: Extending Python with C
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list