How to catch socket timeout?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mickel Grönroos

    #16
    Re: How to catch socket timeout?

    On Wed, 24 Sep 2003, Michael Hudson wrote:
    [color=blue]
    > Paul <paul@oz.net> writes:
    >[color=green]
    > > What's the best way to do this under Python 2.1?
    > > I believe socket.timeout was a 2.3 feature.
    > > Wrap it in threads?[/color]
    >
    > There's Tim O'Malley's timeoutsocket.p y (google for it), which was the
    > inspiration for the feature in 2.3 (though I don't think any code from
    > there actually survived).[/color]

    I can't get the timeoutsocket module to work on my Redhat Linux! (The
    timeout works fine on Windows 2000.) I'm running Python 2.2.2.

    Here's the test code:

    import timeoutsocket
    timeoutsocket.s etDefaultSocket Timeout(1)
    s = timeoutsocket.s ocket(timeoutso cket.AF_INET, timeoutsocket.S OCK_STREAM)
    s.connect(("www .google.com", 80))
    s.close()

    Any ideas?

    /Mickel G.

    Comment

    • Mickel Grönroos

      #17
      Re: How to catch socket timeout?

      On Wed, 24 Sep 2003, Mickel Grönroos wrote:
      [color=blue]
      > On Wed, 24 Sep 2003, Michael Hudson wrote:
      >[color=green]
      > > Paul <paul@oz.net> writes:
      > >[color=darkred]
      > > > What's the best way to do this under Python 2.1?
      > > > I believe socket.timeout was a 2.3 feature.
      > > > Wrap it in threads?[/color]
      > >
      > > There's Tim O'Malley's timeoutsocket.p y (google for it), which was the
      > > inspiration for the feature in 2.3 (though I don't think any code from
      > > there actually survived).[/color]
      >
      > I can't get the timeoutsocket module to work on my Redhat Linux! (The
      > timeout works fine on Windows 2000.) I'm running Python 2.2.2.
      >
      > Here's the test code:
      >
      > import timeoutsocket
      > timeoutsocket.s etDefaultSocket Timeout(1)
      > s = timeoutsocket.s ocket(timeoutso cket.AF_INET, timeoutsocket.S OCK_STREAM)
      > s.connect(("www .google.com", 80))
      > s.close()[/color]

      I might add, that I conducted the test by running the above code
      with and without my Ethernet cable plugged to the computer. When it was
      plugged connect() worked just fine, when unplugged, the connect() call
      timed out on Windows as expected but not at all on Linux.

      /Mickel G.

      --
      Mickel Grönroos, application specialist, linguistics, Research support,CSC
      PL 405 (Tekniikantie 15 a D), 02101 Espoo, Finland, phone +358-9-4572237
      CSC is the Finnish IT center for science, www.csc.fi

      Comment

      • Mickel Grönroos

        #18
        Re: How to catch socket timeout?

        On Wed, 24 Sep 2003, Mickel Grönroos wrote:
        [color=blue]
        > On Wed, 24 Sep 2003, Michael Hudson wrote:
        >[color=green]
        > > Paul <paul@oz.net> writes:
        > >[color=darkred]
        > > > What's the best way to do this under Python 2.1?
        > > > I believe socket.timeout was a 2.3 feature.
        > > > Wrap it in threads?[/color]
        > >
        > > There's Tim O'Malley's timeoutsocket.p y (google for it), which was the
        > > inspiration for the feature in 2.3 (though I don't think any code from
        > > there actually survived).[/color]
        >
        > I can't get the timeoutsocket module to work on my Redhat Linux! (The
        > timeout works fine on Windows 2000.) I'm running Python 2.2.2.
        >
        > Here's the test code:
        >
        > import timeoutsocket
        > timeoutsocket.s etDefaultSocket Timeout(1)
        > s = timeoutsocket.s ocket(timeoutso cket.AF_INET, timeoutsocket.S OCK_STREAM)
        > s.connect(("www .google.com", 80))
        > s.close()[/color]

        I might add, that I conducted the test by running the above code
        with and without my Ethernet cable plugged to the computer. When it was
        plugged connect() worked just fine, when unplugged, the connect() call
        timed out on Windows as expected but not at all on Linux.

        /Mickel G.

        --
        Mickel Grönroos, application specialist, linguistics, Research support,CSC
        PL 405 (Tekniikantie 15 a D), 02101 Espoo, Finland, phone +358-9-4572237
        CSC is the Finnish IT center for science, www.csc.fi

        Comment

        Working...