Python Forum
Multi connection socket server help!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multi connection socket server help!
#1
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Paramiko Server -- Exception (server): Error reading SSH protocol banner ujlain 3 4,644 Jul-24-2023, 06:52 AM
Last Post: Gribouillis
  multi-threaded tcp server-newbie gary 15 3,729 Nov-19-2022, 03:45 PM
Last Post: dreamer
  Socket server problem H84Gabor 0 1,263 Jun-21-2022, 12:14 AM
Last Post: H84Gabor
  Clarification on how to set up non-blocking socket connection Shaggy 1 1,988 Oct-14-2020, 07:57 PM
Last Post: Skaperen
  [Socket] Can a server be accessible from devices not in the same network? SheeppOSU 2 2,987 Jun-18-2020, 01:29 PM
Last Post: DeaD_EyE
  Python script multi client server sonra 1 2,482 Mar-24-2020, 03:49 PM
Last Post: Larz60+
  Writing socket server NewPy_thwan_Programmer 0 1,938 Feb-23-2020, 03:58 PM
Last Post: NewPy_thwan_Programmer
  Server and Network (socket) [WinError 10053] Timxxx 1 4,613 Aug-23-2019, 10:03 AM
Last Post: iMuny
  Python server(Django web site)/client(Python app) connection Junior_Pythoneer 5 3,841 Jul-05-2019, 05:41 PM
Last Post: noisefloor
  Server and Network (socket) [WinError 10053] SheeppOSU 2 22,351 Apr-13-2019, 09:23 PM
Last Post: SheeppOSU

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020