On 03/03/2015 13:43, Francisco Ares wrote:
> Hi, All.
>
> Is there any means to check for the connection status before any read
> or write operation? Or is it enough to try read or write and check the
> result of the operation, and based on that, consider the connection
> status?
You can’t check without trying to read / write (at least in TCP, for RTU
i’m not sure). So yes, you need to check the return value.
>
> And if the connection is lost, be the program a client or a server, is
> the re-connection procedure identical as the first connection, I mean,
> should I delete the context or just keep it and try connecting again?
Delete the context and create a new one. That’s inexpensive, and will
guarantee you a clean start (i remember having had issues with reusing a
context).
Regards,
Julien Blanc