Hi, I have looked at chat-room server and echo server in which there is only one server and multiple clients connected to one server.
I am looking for an example project in which there is only one client and there are multiple servers running. The client will decide which server to send a string message and when.
If using sockets, you could more/less do this with a dictionary of server-name to socket. Then depending on where you want the message to go, you send to that socket in the dict.
I have now managed to run two server programs and one client program on the same machine.
I already had server-client programs running in the same machine. I just modify and run two server programs with one client.
I just copy the server file that makes two server files. I rename them as server1 and server2. The only thing I change in the server file is the port number.
In the client file, I just connect to each server having different port number one-by-one. Latter, I run a while loop in which I first send a string message to the first server and print what I receive and then send the string message to the second server and print what I receive.
I open three terminals and run the files in this order: server1 => server2 => client
This way only one client program is able to connect and communicate with two servers, one at a time.
How can I make GUI on the top of client program ?
I mean when I run the client program in PyCharm, I should able to see ‘buttons’ to connect to server1 and server2. Also the message send/receive fields for each server.