Python Forum
Multi connection socket server help! - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Networking (https://python-forum.io/forum-12.html)
+--- Thread: Multi connection socket server help! (/thread-16231.html)



Multi connection socket server help! - MuntyScruntfundle - Feb-19-2019

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.