libmodbus does handle the reconnecting internally, see
https://libmodbus.org/reference/modbus_set_error_recovery/
Also each libmodbus function will return an error (if so) and set "errno" so can fetch the error from there using "modbus_strerror(errno);"
cheers!