Python socket won't connect on Windows

F

Florian Berger

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
 
G

Grant Edwards

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.
 
F

Florian Berger

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top