how do I use select to timeout a call to accept?

Joshua Muskovitz josh at open.com
Thu Nov 9 01:32:40 EST 2000


I have the line...

        (clientsocket, address) = mylisteningsocket.accept()

...and this blocks until a connection comes in.  I want to be able to have
this timeout periodically so I can check some other things.  Before anyone
suggests using threads, it is already in its own thread.  What it needs to
check is whether it is no longer needed and should kill itself...

Basically, I want to be able to do something like:

    try:
        <magic which either accepts a connection or times out>
        clientsocket, address = <more magic>
    except <it was a timeout>:
        ...

I read (somewhere) that select can be used with accept (and connect and a
bunch of other things), but I can't find any examples of how to do it.
Anyone?

-- josh





-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



More information about the Python-list mailing list