Python socket won't connect on Windows

Discussion in 'Python' started by Florian Berger, Oct 22, 2009.

  1. Hi,

    I have an annoying problem connecting to a remote host via the
    socket module from Python 2.5 / 2.6 on WinXP. :-(

    Short description
    -----------------

    socket.connect(("host", port)) times out with socket.error
    10060, while other applications on the same box can connect
    to the remote site without any problems.

    Long description
    ----------------

    On the remote host in a LAN there is a server listening on port 2020.
    I want to connect to that port via TCP, so what I do is:

    import socket
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect(("192.168.178.12", 2020))

    After a while this returns a socket.error hinting at WinSock error
    10060 which basically says the remote host does not respond.

    The expected behaviour would be that connect() just returns with the
    socket ready to send.


    Software involved
    -----------------

    Python 2.6.2 on Linux 2.6.31-rc3 on the server side

    Python 2.6 and 2.5 on Win XP 64 on the client side


    Things I already tried
    ----------------------

    [x] Basic network checks - ping etc. Network is up and running.

    [x] Using netcat -l -p 2020 as a server replacement. No success.

    [x] Using alternative software on the client side. A browser and telnet
    pointed to 192.168.178.12:2020 can connect at once without any
    problems.

    [x] Turned off any firewall and filtering. No success.

    [x] Using different ports. No success.

    [x] Using Python on Linux on the very same client hardware. Connects
    without problems.

    [x] Python docs.

    [x] WWW search.


    Help! :)
    ---------

    I think I narrowed it down to the fact that Python 2.x on WinXP won't
    connect in this setup.

    Does anyone have a hint what to do?

    Are there known pitfalls with the socket module on Windows?


    Any help will be greatly appreciated.

    Regards,
    Florian
     
    Florian Berger, Oct 22, 2009
    #1
    1. Advertising

  2. On 2009-10-22, Florian Berger <> wrote:

    > I think I narrowed it down to the fact that Python 2.x on
    > WinXP won't connect in this setup.
    >
    > Does anyone have a hint what to do?


    I'd probably fire up Wireshark and capture the network traffic
    to/from the remote host when the Python app attempts to connect
    and when another client connects.

    --
    Grant Edwards grante Yow! I just remembered
    at something about a TOAD!
    visi.com
     
    Grant Edwards, Oct 22, 2009
    #2
    1. Advertising

  3. Hi Grant,

    thanks for the reply!

    > I'd probably fire up Wireshark and capture the network traffic
    > to/from the remote host when the Python app attempts to connect
    > and when another client connects.


    Yes, low level traffic analyzing would have been the next logical step.
    However, mysteriously things started to work after several reboots and
    restarts. Probably a Windows / WinSock issue I don't need to fully
    understand. ^^

    Thanks anyway!

    Florian
     
    Florian Berger, Oct 22, 2009
    #3
    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. Chase Preuninger

    Socket Won't Connect

    Chase Preuninger, Apr 30, 2008, in forum: Java
    Replies:
    7
    Views:
    476
  2. Laszlo Nagy
    Replies:
    1
    Views:
    4,860
    Mark Wooding
    Jan 27, 2009
  3. Jean-Paul Calderone
    Replies:
    0
    Views:
    974
    Jean-Paul Calderone
    Jan 27, 2009
  4. Laszlo Nagy
    Replies:
    0
    Views:
    553
    Laszlo Nagy
    Feb 1, 2009
  5. Steve Holden
    Replies:
    0
    Views:
    669
    Steve Holden
    Feb 1, 2009
Loading...

Share This Page