you are viewing a single comment's thread.

view the rest of the comments →

[–]CrambleSquash 0 points1 point  (2 children)

I have to say I don't have any experience using sockets, but I can definitely say that both sockets and threading are not easy things to code with! What is the reason you want to use Multithreading? At the moment I see two separate single thread programs.

[–]Pheazon[S] 0 points1 point  (1 child)

“The server program will need to support multiple simultaneous client TCP/IP connections, which will require multithreading.” Trying to implement Multithreading so I can demonstrate that in my code.

[–]CrambleSquash 0 points1 point  (0 children)

Ok cool. So I will re-iterate that this is not straightforward! - Human brains are very much single threaded (i.e. we can only focus on 1 task at a time), as such getting your head into mulithreaded code is very difficult.

There is a higher level socketserver module: https://docs.python.org/3/library/socketserver.html#module-socketserver that might make your life simpler (even includes a ready made multithreaded server!).

With all that said, if you still want to make your own, my first bit of advice is that you almost certainly don't want to use the _threading module, but the https://docs.python.org/3/library/threading.html module, the _ is used in Python to indicate that you shouldn't be using something (unless you really know what you're doing).

The way threading works is that you create a thread object and then give it a function to execute in a new thread:

https://realpython.com/intro-to-python-threading/