steveohara / j2mod

Enhanced Modbus library implemented in the Java programming language
Apache License 2.0
276 stars 110 forks source link

ModbusTCPListener does not propagate timeout to slave connections #58

Closed javicacheiro closed 7 years ago

javicacheiro commented 7 years ago

When creating a ModbusTCPListener it accepts to set a timeout for incoming connections but this timeout is not propagated to TCPSlaveConnections.

This means that when you set the timeout of the ModbusTCPListener only affects the original server socket that is listening for connections, but the slave sockets assigned to each incoming connections maintain the Modbus.DEFAULT_TIMEOUT of 3 seconds and it is not possible to change it.

Changing the TCPSlaveConnection timeout is very useful to avoid closing the established master connections after 3 seconds.

I would say that probably most users of the library would expect that when they change the timeout of the listener it will affect also the slave connections created.

It would be possible to set the two timeouts separately but I can not think of many situations where this would be useful, so propagating the timeout seems the most straightforward solution.