Setting timeout for read api
Sat Mar 4 09:01:55 CET 2006
"Swaroop" <tifosi_416 at indiatimes.com> writes:
> PLS HELP..I am working on socket programming as part of my final year
> project. I want to know how to set a timeout on read api that reads
> from a socket. Is it possible using SIGALRM signal?Will setting
> O_NONBLOCK flag of the socket help? Is there any other way to do it?
You could do it with sigalrm but more common is to set a timeout on
the socket (see the settimeout method in the doc). You could also use
select with a timeout, and not read until the select tells you that
data is available.
More information about the Python-list