Stopping a socket.accept() method

Tobias Pfeiffer me at privacy.net
Sun Aug 15 14:00:12 EDT 2004


Hi!

I am writing a network game where the server runs in a console window. 
The person who has opened the server shall be able to stop the process of 
accepting new clients. By now, I am handling that like this:

while 1:
    	try:
    	    	bla = socket.accept()
    	except KeyboardInterrupt:
    	    	break
socket.shutdown(2)

So the user can Ctrl+C and no more clients will be accepted. 
Unfortunately, this doesn't work in Windows. So how can I give the user 
the ability to quit the loop interactively? Any ideas?

Bye
Tobias

-- 
please send any mail to botedesschattens(at)web(dot)de



More information about the Python-list mailing list