socket-module: different behaviour on windows / unix when a timeout is set
Hey, it seems that the socket-module behaves differently on unix / windows when a timeout is set. Here an example: # test.py import socket sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM) print 'trying to connect...' sock.connect(('127.0.0.1',)) print 'connected!' # executed on windows >C:\Python25\python.exe test.py trying to connect... Traceback (most recent call last): File "test.py", line 4, in sock.connect(('127.0.0.1',)) File "", line 1, in connect socket.error: (10061, 'Connection refused') > # executed on linux $ python test.py trying to connect... Traceback (most recent call last): File "test.py", line 4, in sock.connect(('127.0.0.1',)) File "", line 1, in connect socket.error: (111, 'Connection refused') $ Even if the error-codes are different both raise an socket.error with the message 'Connection refused' - good so far. Now I will change the code slightly - to be precise I set a timeout on the socket: # test.py import socket sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM) sock.settimeout(3.0) # <-- print 'trying to connect...' sock.connect(('127.0.0.1',)) print 'connected!' # executed on linux $ python test.py trying to connect... Traceback (most recent call last): File "test.py", line 5, in sock.connect(('127.0.0.1',)) File "", line 1, in connect socket.error: (111, 'Connection refused') $ # executed on windows >C:\Python25\python.exe test.py trying to connect... connected! > The code executed by python running on windows does *not* raise the exception anymore. The Linux does as expected. Is that behaviour common or even documented? Found nothing. It took me lot's of time to figure this out, because there was no exception which was raised when testing for open / ports. When I try to read from the socket (e.g. on port on which nothing runs) I get a timeout after the via settimeou() specified value. Thanks in advance, Mirko -- http://mail.python.org/mailman/listinfo/python-list
Re: socket-module: different behaviour on windows / unix when a timeout is set
Gabriel Genellina wrote: > En Wed, 09 Jul 2008 15:02:56 -0300, Mirko Vogt <[EMAIL PROTECTED]> escribi�: > >> 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 on >> the socket: >> >> >> # test.py >> >> import socket >> sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM) >> sock.settimeout(3.0) # <- >> print 'trying to connect...' >> sock.connect(('127.0.0.1',)) >> print 'connected!' >> >> >> # executed on linux >> >> $ python test.py >> trying to connect... >> Traceback (most recent call last): >> File "test.py", line 5, in >> sock.connect(('127.0.0.1',)) >> File "", line 1, in connect >> socket.error: (111, 'Connection refused') >> $ >> >> >> # executed on windows >> >>> C:\Python25\python.exe test.py >> trying to connect... >> connected! > > Which Python version? Which Windows version? I've tried 2.3.4, 2.4.4, > 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 , as expected. > Hey, this is strange. Linux: $ python --version Python 2.5.2 $ Windows: C:\Python25>python.exe --version Python 2.5.2 C:\Python25> Mirko -- http://mail.python.org/mailman/listinfo/python-list
using python2.6 on windows without installation
Hey, is there a way to use python2.6 without having used the installation routine? When I install python2.6 and copy over the python-directory (C:\programs \python2.6) to another windows host and trying to execute python.exe there, I get an error that python26.dll could not be found. On the host where I used the installation routine, python26.dll is stored in C:\windows\system32 which (obviously) isn't on the host where I just copied the python directory to. Is it possible to include python26.dll in the application folder or tell python not to look in C:\windows\system32 for its library? Backround is: I'd like to put the python directory on a share which is mounted by several windows hosts. That way I do not need to touch every windows host when I'm going to update a python installation but just the one which is sharing it to all others. Thanks a lot in advance! mirko -- This email address is used for mailinglist purposes only. Non-mailinglist emails will be dropped automatically. If you want to get in contact with me personally, please mail to: mirko.vogt nanl de -- http://mail.python.org/mailman/listinfo/python-list
Re: using python2.6 on windows without installation
Thanks a lot for all your solutions! Tried installing it "just for the current user" as suggested by Christian and it works like a charme, so there seems to be no need for another python distribution in this case. Thanks a lot once again! mirko On Fri, 2010-04-30 at 01:34 +0200, Christian Heimes wrote: > Mirko Vogt wrote: > > Hey, > > > > is there a way to use python2.6 without having used the installation > > routine? > > > > When I install python2.6 and copy over the python-directory (C:\programs > > \python2.6) to another windows host and trying to execute python.exe > > there, I get an error that python26.dll could not be found. > > > > On the host where I used the installation routine, python26.dll is > > stored in C:\windows\system32 which (obviously) isn't on the host where > > I just copied the python directory to. > > > > Is it possible to include python26.dll in the application folder or tell > > python not to look in C:\windows\system32 for its library? > > You need to include more than just python26.dll. The correct MSVCRT > version must be shipped with your package or it has to be installed by > your users. > > Fear not, my friend! The solution for your quest is easy to come by. > Install Python 2.6 again but this time chose "install only for me" > instead of "for all users". With this option all necessary files land > into one directory. As long as you have no need for fancy stuff like COM > and Windows services you have to worry about python26.dll in Windows' > system32 directory. > > At work we run our entire application stack including Python2.6, tons of > Python packages with extensions, a complete Java runtime environment and > a pile of DLLs from svn. Works like a charm. > > Christian > -- This email address is used for mailinglist purposes only. Non-mailinglist emails will be dropped automatically. If you want to get in contact with me personally, please mail to: mirko.vogt nanl de -- http://mail.python.org/mailman/listinfo/python-list