473,396 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Re: socket-module: different behaviour on windows / unix whena timeout is set

Gabriel Genellina wrote:
En Wed, 09 Jul 2008 15:02:56 -0300, Mirko Vogt <li***@nanl.deescribi�:
>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_STR EAM)
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.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 9999, 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
Jul 11 '08 #1
0 961

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Achim Domma | last post by:
Hi, I'm using Python 2.3s timeout sockets and have code like this to read a page from web: request = ... self.page = urllib2.urlopen(request) and later:
0
by: Tim Williams | last post by:
(python newbie) Is it possible to individually set the socket timeout of a connection created by smtplib, rather than use the socket.setdefaulttimeout() value used by the rest of the...
1
by: John Hunter | last post by:
I have a test script below which I use to fetch urls into strings, either over https or http. When over https, I use m2crypto.urllib and when over http I use the standard urllib. Whenever, I...
0
by: Tarek Ziadé | last post by:
Hello, anyone knows a way to deal with this problem ? http://sourceforge.net/tracker/index.php?func=detail&aid=1153016&group_id=5470&atid=105470 This bug has been fixed in 2.3 but there is...
0
by: Paola | last post by:
Hi, I have a very strange problem with PowerTCP: I made a wrapper between a server web and the browsers. If the client ask Html pages or images there is no problem instead if the client ask a pdf...
1
by: Franky | last post by:
Hello, How can I set timeout on the send for an asynchronous socket? I use the setsocketoption's timeout but it does not seem work. The program is blocked at the socket's EndSend step until the...
0
by: Jaap Spies | last post by:
Hi, Running Fedora Core 4: Python 2.4.3 and Python 2.4.1. I'm getting: IOError: (2, 'No such file or directory') all the time. Trying to track down this problem: Python 2.4.1 (#1, May 16...
5
by: yawnmoth | last post by:
Say I have the following script: <? $timeout = 5; $start = time(); $fsock = fsockopen('125.1.119.10',80,$errno,$errstr,$timeout); // reduce $timeout by the amount of time that it took for...
1
by: samido | last post by:
Guys, anyone ever experience this on the server and know how to solve it? it happenes when I try to copy and paste(deploy) some .ear and .jar files on the server(JBoss) ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.