aboutsummaryrefslogtreecommitdiff
path: root/computer-network-experiment/client.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-06-08 18:25:36 +0800
committercrupest <crupest@outlook.com>2021-06-08 18:25:36 +0800
commitf27bda8e8d7fcfe82ad20d345c63d327ff047b11 (patch)
treec2ff251ec1b7c769fb8b4d8fde42e8c9cec74978 /computer-network-experiment/client.cpp
parentfcd0d3aaea9b6a312565e95ad191b5bef17dd541 (diff)
downloadlife-f27bda8e8d7fcfe82ad20d345c63d327ff047b11.tar.gz
life-f27bda8e8d7fcfe82ad20d345c63d327ff047b11.tar.bz2
life-f27bda8e8d7fcfe82ad20d345c63d327ff047b11.zip
...
Diffstat (limited to 'computer-network-experiment/client.cpp')
-rw-r--r--computer-network-experiment/client.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/computer-network-experiment/client.cpp b/computer-network-experiment/client.cpp
index c206856..73ae52f 100644
--- a/computer-network-experiment/client.cpp
+++ b/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."));
+ }
}
}