Re: select.select and socket.setblocking

Discussion in 'Python' started by Jean-Paul Calderone, Dec 30, 2008.

  1. On Tue, 30 Dec 2008 19:19:08 +0100, Francesco Bochicchio <> wrote:
    > [snip]
    >
    >If you are interested in socket errors, you should
    >also fill the third 'fd-set' in the select call, and after select returns
    >check that fd is not in it anymore:
    >
    >ready = select.select( [fd],[], [fd] )
    >if fd in ready[2]:
    > # raise your error here


    The third argument to select() isn't for monitoring sockets for errors. Its
    behavior is also rather platform sensitive. In general, you don't need it
    at all on POSIX, but on Windows you should pass the same list for it as you
    pass for the write-set, merge the results, and treat them all as writeable.

    Or use a higher-level library that deals with all the asinine details for
    you. ;)

    Jean-Paul
     
    Jean-Paul Calderone, Dec 30, 2008
    #1
    1. Advertising

  2. Jean-Paul Calderone ha scritto:
    > On Tue, 30 Dec 2008 19:19:08 +0100, Francesco Bochicchio
    > <> wrote:
    >> [snip]
    >>
    >> If you are interested in socket errors, you should
    >> also fill the third 'fd-set' in the select call, and after select
    >> returns check that fd is not in it anymore:
    >>
    >> ready = select.select( [fd],[], [fd] )
    >> if fd in ready[2]:
    >> # raise your error here

    >
    > The third argument to select() isn't for monitoring sockets for errors.
    > Its
    > behavior is also rather platform sensitive. In general, you don't need it
    > at all on POSIX, but on Windows you should pass the same list for it as you
    > pass for the write-set, merge the results, and treat them all as writeable.
    >
    > Or use a higher-level library that deals with all the asinine details for
    > you. ;)
    >
    > Jean-Paul


    Yes, now that you mention it I remember having to do something like that
    on a socket library I wrote on windows ... IIRC, the send could not
    complete and then signal the readyness of the socket through
    the third argument of the select ...

    My experience is mostly on unices, and I usually don't use the third
    argument (and not often the second) but I remember having read on
    select manual page that it was for errors. Now both python manuals
    than select manual page say it is for 'exceptional conditions', without
    going into details ...

    Tx for the clarification, anyway ...

    Ciao
    ----
    FB
     
    Francesco Bochicchio, Dec 31, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laszlo Nagy

    select.select and socket.setblocking

    Laszlo Nagy, Dec 30, 2008, in forum: Python
    Replies:
    12
    Views:
    1,188
    Roy Smith
    Jan 3, 2009
  2. Jean-Paul Calderone

    Re: select.select and socket.setblocking

    Jean-Paul Calderone, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    456
    Jean-Paul Calderone
    Dec 30, 2008
  3. Laszlo Nagy
    Replies:
    1
    Views:
    4,858
    Mark Wooding
    Jan 27, 2009
  4. Jean-Paul Calderone
    Replies:
    0
    Views:
    973
    Jean-Paul Calderone
    Jan 27, 2009
  5. Laszlo Nagy
    Replies:
    0
    Views:
    553
    Laszlo Nagy
    Feb 1, 2009
Loading...

Share This Page