determining how much data is on a socket

Erno Kuusela erno-news at erno.iki.fi
Sun Dec 17 11:25:53 EST 2000


In article <91gu7q$6pj$1 at bob.news.rcn.net>, "Z 3 Penguin"
<z3penguin at penguinpowered.com> writes:

[reformatted - please keep your lines under 73 characters long]

| is there any way to find out how much data is waiting on a given
| socket?
[...]
| i would like to know if the bytes are waiting before i read, so that
| if they are not, my program can continue and try to read it later.
| any ideas?

you can't do this portably. most unixish systems support the
FIONREAD ioctl on sockets which does this.

the normal way to deal with this situation is to use select and/or
non-blocking sockets.

  -- erno



More information about the Python-list mailing list