Pb when connecting to unopened ports and using socket timeout

Discussion in 'Python' started by popov, Sep 9, 2003.

  1. popov

    popov Guest

    Hello,

    When using the timeout option with a socket object (python 2.3), I
    don't have the same behaviour under Windows than under Linux / Mac.

    Specifically, if trying to connect to an unopened port of the
    localhost, I get a timeout exception on Windows (tested under W2K
    Server), whereas I get a "111 - Connection Refused" exception on Linux
    and "22 - Invalid Argument" on Mac (OS X).

    Even if the error message under Mac is not really appropriate, I think
    that the behaviour under Linux and Mac is the right one, in that it
    sends (quickly) an error message and not timeouting.

    Note that when using blocking socket the behaviour is ok under all
    platforms: they each return back quickly a "Connection refused" error
    message (err codes are different depending on the platform (61=Mac,
    111=Linux, 10061=Windows)).

    What do you think ?

    I heard that the timeout option was implemented based on Timothy
    O'Malley timeoutsocket.py. Then, maybe the pb can come from the usage
    of select in the connection function: select is not asked to get back
    exceptions in the returned triple, whereas I think some errors can be
    returned back through this mean under Windows (according to Tip 25 of
    Jon C. Snader book's "Effective TCP/IP Programming"). So, by not
    checking the returned exceptions, we would miss the "connection
    refused" error and get instead the timeout error...
     
    popov, Sep 9, 2003
    #1
    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. VJN
    Replies:
    0
    Views:
    655
  2. =?ISO-8859-15?Q?Fr=E9d=E9ric_Lochon?=

    connecting std_logic inout ports and std_logic_vector inout port

    =?ISO-8859-15?Q?Fr=E9d=E9ric_Lochon?=, Nov 6, 2007, in forum: VHDL
    Replies:
    3
    Views:
    866
  3. mreister
    Replies:
    1
    Views:
    3,238
    mreister
    May 25, 2010
  4. Mark Probert

    Timeout::timeout and Socket timeout

    Mark Probert, Oct 6, 2004, in forum: Ruby
    Replies:
    1
    Views:
    1,310
    Brian Candler
    Oct 6, 2004
  5. Shmuel (Seymour J.) Metz
    Replies:
    0
    Views:
    345
    Shmuel (Seymour J.) Metz
    May 21, 2006
Loading...

Share This Page