Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows XP Socket Trouble

Status
Not open for further replies.

eamc

Technical User
Sep 3, 2001
83
US
Hi - I am a Python novice running under Windows XP. Everything works fine, but after I have worked for some 2 hours, I suddently get 2 messages: "Socket Error: Connection Refused" and "IDLE's subprocess didn't make connection. Either IDLE cannot start a subprocess or a personal firewall is blocking the connection." Then I have to reboot, and everything is OK. This has happened 3-4 times, and always requires at least 2 hours' work.

It seems unlikely that a Symantec Firewall (which I have) is acting up only after 2 hours?
 
Have you tried using PythonWin IDE instead of Idle?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
First I will just tell you to make sure you have downloaded and installed Patch #909005 from Microsoft's Update. Keeping your windows updated all the time is the only thing that will keep you sane. If that doesnt work. Keep reading.

asyncore is broken for windows if connection is refused
asyncore.poll is broken on windows. If a connection is
refused happens it will hang for ever and never raise
an exception.

The Select statment never checks the exfds. This is
needed as this is where windows reports failed
connections. The documentation in the microsoft
platform SDK mentions this.


The suggested fix is shown below althought this is
untested. The correct error number is recived from
getsockopt(SOL_SOCKET,SO_ERROR)

def poll(timeout=0.0, map=None):
if map is None:
map = socket_map
if map:
r = []; w = []; e = []
for fd, obj in map.items():
if obj.readable():
r.append(fd)
if obj.writable():
w.append(fd)

if sys.platform == 'win32':
if not obj.connected:
e.append(fd)
if [] == r == w == e:
time.sleep(timeout)
else:
try:
r, w, e = select.select(r, w, e, timeout)
except select.error, err:
if err[0] != EINTR:
raise
else:
return

if sys.platform == 'win32':
for fd in e:
obj = map.get(fd)
if obj is None:
continue
errno =
fs.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
raise
socket.error,(errno,socketerrorTab[error])

for fd in r:
obj = map.get(fd)
if obj is None:
continue
read(obj)

for fd in w:
obj = map.get(fd)
if obj is None:
continue
write(obj)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top