modbus_connect() timeout

1,196 views
Skip to first unread message

harl...@googlemail.com

unread,
Jun 30, 2015, 8:34:06 AM6/30/15
to libm...@googlegroups.com
Hello,

I needed the ability to set a defined timeout period for modbus_connect() on a TCP connection. This is for periodically trying to (re-)connect to a device which may be switched off or unplugged. The default linux kernel socket connect() timeout period of about 20s is much too long for me.

The appended patch adds a new method modbus_connect_with_timeout(modbus_t *ctx, unsigned long timeout_ms) for this issue. The "old" method modbus_connect(modbus_t *ctx) internally sets the timeout to 20000ms. It's only for Linux and only for TCP connections at the moment, but it's a starting point for a further release implementation.

Cheers,

Felix
libmodbus-3.0.6_connect_with_timeout.patch

Stéphane Raimbault

unread,
Jul 11, 2015, 9:26:28 PM7/11/15
to libm...@googlegroups.com
Hi,

The 3.0 branch is in feature freeze and in 3.1 branch, the timeout of connect() is already defined by the response timeout.



Stéphane

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "libmodbus".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse libmodbus+...@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages