catch non-blocking socket exceptions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Axel Bock

    catch non-blocking socket exceptions

    Hi all,

    I try to connect to several hosts at once to verify whether a certain
    service is running. Now it's quite stupid to connect to one after another,
    cause if I do this I'll wait forever if some hosts don't respond (at least
    until TCP timeout).

    But if I connect to several hosts in parallel and use polling objects I'm
    stuck - I don't know how to handle exceptions: are they raised as normal?
    If yes, how do I get the correspondig socket object - or file number?
    If no, how do I know if a socket timed out, or refused connection, or
    something similar?


    Thanks for any hints & greetings,

    Axel.
  • Axel Bock

    #2
    Re: catch non-blocking socket exceptions

    Am Thu, 26 Jun 2003 17:03:11 +0200 schrieb Axel Bock:
    [color=blue]
    > Hi all,
    >
    > I try to connect to several hosts at once to verify whether a certain
    > [...blorf...]
    >[/color]

    or better still - does someone know how to set the tcp timeout value? THIS
    would greatly simplyfy my task :-)


    Thanks again & greetings (again),

    Axel.

    Comment

    • Peter Hansen

      #3
      Re: catch non-blocking socket exceptions

      Axel Bock wrote:[color=blue]
      >
      > I try to connect to several hosts at once to verify whether a certain
      > service is running. Now it's quite stupid to connect to one after another,
      > cause if I do this I'll wait forever if some hosts don't respond (at least
      > until TCP timeout).
      >
      > But if I connect to several hosts in parallel and use polling objects I'm
      > stuck - I don't know how to handle exceptions: are they raised as normal?
      > If yes, how do I get the correspondig socket object - or file number?
      > If no, how do I know if a socket timed out, or refused connection, or
      > something similar?[/color]

      Check out these pages for some background (especially page four on non-blocking
      sockets):



      But consider just using Twisted and letting all this stuff be handled
      for you... no sense reinventing the wheel in an area that is notoriously
      difficult to do right.

      -Peter

      Comment

      • Axel Bock

        #4
        Re: catch non-blocking socket exceptions

        Am Thu, 26 Jun 2003 11:17:02 -0400 schrieb Peter Hansen:
        [color=blue]
        > Check out these pages for some background (especially page four on
        > non-blocking sockets):
        >
        > http://www.mcmillan-inc.com/sock1.html[/color]

        great link :-) i forgot about select I admit ...
        [color=blue]
        > But consider just using Twisted and letting all this stuff be handled
        > for you... no sense reinventing the wheel in an area that is
        > notoriously difficult to do right.[/color]

        hm. twisted. yeah.
        I tried it for the udp approach for the same problem, and ended up writing
        the stuff by myself - the udp thing in twisted is rather ... twisted :-)
        (and I do not consider the documentation/howtos/examples to be useful for
        beginners in any way).

        for tcp it might be worth a try ... although its really a quite simple
        problem and twisted a rather large solution :-)


        thanks,

        axel.

        Comment

        • Alan Kennedy

          #5
          Re: catch non-blocking socket exceptions

          Axel Bock wrote:
          [color=blue]
          > hm. twisted. yeah.
          > I tried it for the udp approach for the same problem, and ended up
          > writing
          > the stuff by myself - the udp thing in twisted is rather ... twisted :-)
          > (and I do not consider the documentation/howtos/examples to be useful for
          > beginners in any way).
          >
          > for tcp it might be worth a try ... although its really a quite simple
          > problem and twisted a rather large solution :-)[/color]

          Perhaps something like Spread is closer to what you need?

          The official home of the Python Programming Language


          *Very* easy to get up and running, built for working with UDP, easy to configure
          ......

          Just an alternative suggestion.

          --
          alan kennedy
          -----------------------------------------------------
          check http headers here: http://xhaus.com/headers
          email alan: http://xhaus.com/mailto/alan

          Comment

          Working...