Python socket won't connect on Windows

Florian Berger florib at arcor.de
Thu Oct 22 07:22:57 EDT 2009


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




More information about the Python-list mailing list