File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -235,3 +235,23 @@ def open_connection(host, port):
235
235
s = yield IOWrite (s )
236
236
log .debug ("open_connection: After iowait: %s" , s )
237
237
return StreamReader (s ), StreamWriter (s )
238
+
239
+
240
+ def start_server (client_coro , host , port ):
241
+ log .debug ("start_server(%s, %s)" , host , port )
242
+ s = _socket .socket ()
243
+ s .setblocking (False )
244
+
245
+ ai = _socket .getaddrinfo (host , port )
246
+ addr = ai [0 ][4 ]
247
+ s .setsockopt (_socket .SOL_SOCKET , _socket .SO_REUSEADDR , 1 )
248
+ s .bind (addr )
249
+ s .listen (10 )
250
+ while True :
251
+ log .debug ("start_server: Before accept" )
252
+ yield IORead (s )
253
+ log .debug ("start_server: After iowait" )
254
+ s2 , client_addr = s .accept ()
255
+ s2 .setblocking (False )
256
+ log .debug ("start_server: After accept: %s" , s2 )
257
+ yield client_coro (StreamReader (s2 ), StreamWriter (s2 ))
You can’t perform that action at this time.
0 commit comments