it seems that the socket-module behaves differently on unix / windows[...]
when a timeout is set.
Now I will change the code slightly - to be precise I set a timeout onWhich Python version? Which Windows version? I've tried 2.3.4, 2.4.4,
the socket:
# test.py
import socket
sock=socket.socket(socket.AF_INET,socket.SOCK_STRE AM)
sock.settimeout(3.0) # <-----
print 'trying to connect...'
sock.connect(('127.0.0.1',9999))
print 'connected!'
# executed on linux
$ python test.py
trying to connect...
Traceback (most recent call last):
File "test.py", line 5, in <module>
sock.connect(('127.0.0.1',9999))
File "<string>", line 1, in connect
socket.error: (111, 'Connection refused')
$
# executed on windows
>C:\Python25\python.exe test.pytrying to connect...
connected!
2.5.1 and 3.0a4, all on WinXP SP2, and in all cases I got an exception
(details differ between versions). In no case I could make the connection
succeed when nobody was listening at port 9999, as expected.
--
Gabriel Genellina