nanoMODBUS Server Support for Multiple Clients
type18 opened this issue · 1 comments
Hello! I'm trying to use the nanoMODBUS for a server. I'm not sure how to use the code to support multiple clients. I reviewed the Linux example. It appears to poll the clients one at a time. This can create long delays when a client is slow or drops off. This will cause problems in my application. Is there a way for each client connection to have its own thread so they don't have to wait for other clients? Thanks!
The implementation of the linux TCP server made for the examples, examples/linux/platform.h
, should already work fine in your case.
It is based on select()
at its core (the one inside server_poll()
here), which as general approach works very well for the multiple clients case most of the times, without resorting to threads. It immediately returns whenever a new TCP connection or data from an existing connection are received, so you can be sure that your server will always react timely to any event coming from the clients, and it won't be disrupted from slow/bad clients.
If you didn't do it already, can you try it in your application and see if it works? In case it doesn't we'll try to tune it to better suit your needs