stephane / libmodbus

A Modbus library for Linux, Mac OS, FreeBSD and Windows
http://libmodbus.org
GNU Lesser General Public License v2.1
3.29k stars 1.71k forks source link

When I use modbus tcp master mode, how do I know that the slave has closed the connection? #713

Open jhembedded opened 10 months ago

jhembedded commented 10 months ago

When I use modbus tcp master mode, how do I know that the slave has closed the connection?

oe5hpm commented 10 months ago

once "modbus_receive" returns -1 you can be sure that the connection is dead ....

you have to close the active socket like this: close(modbus_get_socket(tcp_srv_mb));