<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
<small>Hi all,<br>
<br>
I seem to have a problem while trying to reconnect to a (stackless)
socket, after a first connection failure.<br>
<br>
In fact, when a first connect fails, it seems that the second will
always block forever (no matter if that one should fail or succeed).<br>
<br>
Did I miss something ?<br>
<br>
Nike.<br>
<br>
<br>
<br>
<br>
# -*- coding: utf-8 -*-<br>
import socket,time<br>
import stackless,stacklesssocket,stackless_addins<br>
<br>
def tst():<br>
<br>
  address=('</small><small>91.121.29.211</small><small>',1234)  </small><small>####
Failing (rejected)</small><br>
<small>  print 'started'<br>
<br>
  s=None<br>
  print("Initiating connection to %s:%s" %(address[0],address[1]))<br>
<br>
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br>
  print('starting connect to %s:%s' %address)<br>
<br>
  #s.setblocking(0)<br>
  s.connect(address)<br>
  print'connect finished!'<br>
  s.close()<br>
<br>
  stackless_addins.TaskletSleep(5)<br>
<br>
</small><small>  #address=('</small><small>91.121.29.211</small><small>',1234) 
</small><small>#### Failing (rejected)</small><br>
<small>  address=('91.121.29.211',80) #### Working <br>
  print('\n\nSecond attempt\n')<br>
<br>
  s=None<br>
  print("Initiating connection to %s:%s" %(address[0],address[1]))<br>
<br>
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br>
  print('starting connect to %s:%s' %address)<br>
<br>
  s.setblocking(0)<br>
  s.connect(address)<br>
  print'connect finished!'<br>
  s.close()<br>
<br>
<br>
<br>
stacklesssocket.install()<br>
stackless_addins.sleepingTasklets = []<br>
stackless.tasklet(stackless_addins.ManageSleepingTasklets)()<br>
<br>
<br>
stackless.tasklet(tst)()<br>
stackless.run()<br>
</small>
</body>
</html>