@@ -161,24 +161,21 @@ def local_connect_and_auth(port, auth_secret):
161161 # On most of IPv6-ready systems, IPv6 will take precedence.
162162 for res in socket .getaddrinfo ("127.0.0.1" , port , socket .AF_UNSPEC , socket .SOCK_STREAM ):
163163 af , socktype , proto , _ , sa = res
164- sock = socket .socket (af , socktype , proto )
165164 try :
165+ sock = socket .socket (af , socktype , proto )
166166 sock .settimeout (15 )
167167 sock .connect (sa )
168+ sockfile = sock .makefile ("rwb" , 65536 )
169+ _do_server_auth (sockfile , auth_secret )
170+ return (sockfile , sock )
168171 except socket .error as e :
169172 emsg = _exception_message (e )
170173 errors .append ("tried to connect to %s, but an error occured: %s" % (sa , emsg ))
171174 sock .close ()
172175 sock = None
173- continue
174- break
175- if not sock :
176+ else :
176177 raise Exception ("could not open socket: %s" % errors )
177178
178- sockfile = sock .makefile ("rwb" , 65536 )
179- _do_server_auth (sockfile , auth_secret )
180- return (sockfile , sock )
181-
182179
183180def ensure_callback_server_started (gw ):
184181 """
0 commit comments