DEV Community

Srikanth Anantharam
Srikanth Anantharam

Posted on

Need help on implementing client-server communication in Python

I'm trying to create a client-server model using Python where the client sends a request. The server receives it and spawn a process/thread to handle the request and when it's done sends the result back to the client. The server should be able to handle multiple clients and hence multiple requests without any issues. The server must have some kind of session management maintaining client & request details. How should I implement this. Can someone help me?

This is my first big task at work & I'm excited.

Top comments (2)

Collapse
 
biskit1943 profile image
Maximilian Konter

Well, a bit more detail would be nice. How should the communication be done? Socket? HTTP ? Which Python version can you use? If you're on Python 3.7+ and want to use HTTP then I can really recommend fastapi wich ist super nice. Else I'm not having any experience yet or I don't know any frameworks.

Collapse
 
forfdev profile image
Andrew Spittlemeister

I second the fastapi if you are going to go with HTTP, it is both easy to use and opens up the possibility of using async if you are able to and are comfortable with it. If this isn't an HTTP type of project, I would suggest ZeroMQ for your protocol, it's not the easiest to learn in the beginning but it is certainly easier to work with than raw sockets in the long run (they even have a client-server example that you can expand on).

If you need a message broker (although it doesn't sound like you do), you could give RabbitMQ a look.