Python Forum

Full Version: Multi connection socket server help!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
If I have the following:

def Server():

	host='0,0,0,0'
	port=12345
	print("Server....opening port " + str(host) + "  " + str (port))
	sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	serveraddress=(host, port)
	sock.bind(serveraddress)
	sock.listen(200)

	while True:
		clientsocket, clientaddress=sock.accept()
		thread.start_new_thread(Handler, (clientsocket, clientaddress))
The theory in my head says this will accept multiple connections at 'the same time' and pass the input off to the Handler function. Is this correct? Or will this socket be blocked at this point? The Handler function will have one action per instruction received then die..

The blocking confuses me a bit, the other languages I've used don't work quite the same way.

Many thanks.