For that, it might possible to switch to use http://libmodbus.org/docs/v3.1.4/modbus_new_tcp_pi.html instead of _modbus_new_tcp_ in the libmodbus.