Python Forum
Multiple network socket servers? - 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: Multiple network socket servers? (/thread-14064.html)



Multiple network socket servers? - MuntyScruntfundle - Nov-13-2018

Hi there.

Sockets confuse me, even with a fairly simple set of handshakes I get fuddled!

I have a number of unix servers, just as an exercise I want to send a small packet of data randomly around the network. Each machine will run a socket server and has a BlinkStick attached to give the user some feedback.

So with the socket code running on all machines I need the following:

Machine 1 randomly chooses an ip address xxx,xxx,xxx,45
Machine 1 sends "Hello"
Machine 45 replies "Im here"
Machine 1 sends "DATA PACKET".
Machine 45 replies "Got it"

Machine 45 then repeats the process. (obviously with error and condition trapping)

Where I'm getting confused is: Socket server code can handle all of the above, except sending the Hello and the PACKET. So I'm handling all the conditional code in the Sock Server??

I don't have any sample code at the moment, I want to get the process sorted in my head before I start writing something completely wrong!

Any ideas welcome. Are there any socket wrappers that might make this easier?
Latency is not an issue as there will be lots of 'sleeps' so the user can see what's going on.

Many, many thanks.


RE: Multiple network socket servers? - wavic - Nov-13-2018

In short, a server is a program which is listening to a port. It can take some actions once a connection is established. For example, sending back an answer or connecting to another listener. Whatever is necessary. So it can behave as a server and a client. A proxy server is such a program.