File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 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):
235235 s = yield IOWrite (s )
236236 log .debug ("open_connection: After iowait: %s" , s )
237237 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