diff --git a/src/tcp_client.h b/src/tcp_client.h index 39c851d..0bc8391 100644 --- a/src/tcp_client.h +++ b/src/tcp_client.h @@ -193,8 +193,18 @@ class BridgeTCPClient : public Client { } MsgPack::arr_t message; - RpcCall async_rpc = bridge->call(TCP_READ_METHOD, connection_id, size, read_timeout); - const bool ret = async_rpc.result(message); + bool ret; + int err; + + if (read_timeout > 0) { + RpcCall async_rpc_timeout = bridge->call(TCP_READ_METHOD, connection_id, size, read_timeout); + ret = async_rpc_timeout.result(message); + err = async_rpc_timeout.getErrorCode(); + } else { + RpcCall async_rpc = bridge->call(TCP_READ_METHOD, connection_id, size); + ret = async_rpc.result(message); + err = async_rpc.getErrorCode(); + } if (ret) { for (size_t i = 0; i < message.size(); ++i) { @@ -202,7 +212,7 @@ class BridgeTCPClient : public Client { } } - if (async_rpc.getErrorCode() > NO_ERR) { + if (err > NO_ERR) { _connected = false; }