diff --git a/include/snipplib/network/snplib_network_asio.h b/include/snipplib/network/snplib_network_asio.h index 606ca00..2c1ab86 100644 --- a/include/snipplib/network/snplib_network_asio.h +++ b/include/snipplib/network/snplib_network_asio.h @@ -71,14 +71,12 @@ public: { auto msg_bytes = msg.toBytes(); auto net_bytes = _reprProto.toNetwork(msg_bytes); - if (net_bytes.flag != net_connection_t::net_repr_proto_t::result_flag_t::OK) { - } switch (net_bytes.flag) { case net_connection_t::net_repr_proto_t::result_flag_t::NOT_ENOUGH_DATA: - co_return std::errc::message_size; + co_return std::make_error_code(std::errc::message_size); case net_connection_t::net_repr_proto_t::result_flag_t::INVALID_DATA: - co_return std::errc::invalid_argument; + co_return std::make_error_code(std::errc::invalid_argument); default: break; } @@ -137,7 +135,14 @@ public: co_return ec; } - ::asio::awaitable recv() {} + ::asio::awaitable recv() + { + thread_local static ::asio::steady_timer timeout_timer(_socket.get_executor()); + + auto start_tp = std::chrono::steady_clock::now(); + + timeout_timer.expires_after(_recvTimeout); + } ::asio::awaitable close() {}