kochedykov / jlibmodbus

JLibModbus - is an implementation of the Modbus protocol v1.1b in java language. Java modbus library. It works. Welcome.
http://kochedykov.github.io/jlibmodbus/
Apache License 2.0
299 stars 128 forks source link

Enable TCP_NODELAY for all TCP connections #57

Closed wielantu closed 3 years ago

wielantu commented 3 years ago

The Modbus specification (https://modbus.org/docs/Modbus_Messaging_Implementation_Guide_V1_0b.pdf chapter 4.3.2) recommends to use TCP_NODELAY so it should be enabled for all TCP connections.

I have observed some cases where a modbus request sent by jlibmodbus was delayed for several 100 ms. In case the delay is larger than the configured read timeout this leads to a SocketTimeoutException. Enabling TCP_NODELAY hopefully fixes this problem.