Split the original modbus_receive function in two functions to avoid the strange -1 value to ignore the sockfd argument.