From f7d73f1bf08aaca98e789a6d6c56d672cc0c4c9f Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 8 Jun 2021 18:25:36 +0800 Subject: import(life): ... --- works/life/computer-network-experiment/client.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'works/life/computer-network-experiment/client.cpp') diff --git a/works/life/computer-network-experiment/client.cpp b/works/life/computer-network-experiment/client.cpp index c206856..73ae52f 100644 --- a/works/life/computer-network-experiment/client.cpp +++ b/works/life/computer-network-experiment/client.cpp @@ -75,9 +75,12 @@ int Main() { break; } - std::string s = SafeReadUntil(client_socket, '\n', rest); + std::string data; + if (!SafeReadUntil(client_socket, '\n', data, rest)) { + PrintErrorMessageAndExit(CRUT("Failed to receive message.\n")); + } - SendOutput(CRUT("Recived a message:\n{}\n"), ConvertCharString(s)); + SendOutput(CRUT("Recived a message:\n{}\n"), ConvertCharString(data)); } }); receive_thread.detach(); @@ -89,7 +92,9 @@ int Main() { std::string s; if (send_queue.read(s)) { - SafeSend(client_socket, s); + if (!SafeSend(client_socket, s)) { + PrintErrorMessageAndExit(CRUT("Failed to send message to server.")); + } } } -- cgit v1.2.3