Adding TCP server handling to libmodbus
When creating a modbus server you must create your own TCP / socket server handling for libmodbus. This commit aims to integrate this handling into libmodbus since 9 out of 10 users has to make the exact same code.
Features:
- Function to create a TCP server context where you specify port, ip and max_connection.
- Handle function which must be called from a task or loop.
- Destroy function with cleans up and correctly closes all current connections.
- Function to change select timeout
Uses the modbus specifications method of 'disconnecting the last used connection if max_connection is reached' when accepting new incoming connections.
Still missing the 'prioritized IP' functionality which is also mentioned in the modbus specification but I might add that at a later date :)
Some feedback would be nice :)
This is awesome! Thank you! I think your patches should be included in the next libmodbus release.
Anything that needs to be done in order to get this merged?