Data available on socket?
Nicolas
n.favrefelix at eggbaconandspam--free.fr
Fri Jul 22 12:47:59 EDT 2005
Jan Danielsson a écrit :
> Hello all,
>
> How do I find out if a blocking socket has data available [for
> reading] on it?
>
> I assume I could do something like this:
>
> tmp = self.read(1, socket.MSG_PEEK)
> if len(tmp) > 0:
> # Data available
>
> But is there a better way? A call which specifically checks if data
> is available?
Hello,
You might want to use select.select.
See http://effbot.org/librarybook/select.htm for an example with sockets.
Nicolas.
More information about the Python-list
mailing list