diff options
author | crupest <crupest@outlook.com> | 2021-06-07 20:33:23 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-06-07 20:33:23 +0800 |
commit | 2bc323cfa5d317188da591413bce7f1230e383b4 (patch) | |
tree | fa7c70a0012c17d376191642c31261d3bb5513b7 /works/life | |
parent | c10e08c3896343cc7ddffe1dd7b1d09da2f8548e (diff) | |
download | crupest-2bc323cfa5d317188da591413bce7f1230e383b4.tar.gz crupest-2bc323cfa5d317188da591413bce7f1230e383b4.tar.bz2 crupest-2bc323cfa5d317188da591413bce7f1230e383b4.zip |
import(life): ...
Diffstat (limited to 'works/life')
-rw-r--r-- | works/life/computer-network-experiment/.vscode/launch.json | 16 | ||||
-rw-r--r-- | works/life/computer-network-experiment/Common.cpp | 2 | ||||
-rw-r--r-- | works/life/computer-network-experiment/client.cpp | 4 |
3 files changed, 19 insertions, 3 deletions
diff --git a/works/life/computer-network-experiment/.vscode/launch.json b/works/life/computer-network-experiment/.vscode/launch.json new file mode 100644 index 0000000..882a540 --- /dev/null +++ b/works/life/computer-network-experiment/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Launch server.", + "type": "gdb", + "request": "launch", + "target": "${workspaceRoot}/build/server", + "cwd": "${workspaceRoot}", + "valuesFormatting": "parseText" + } + ] +}
\ No newline at end of file diff --git a/works/life/computer-network-experiment/Common.cpp b/works/life/computer-network-experiment/Common.cpp index 22f8b63..e4615fc 100644 --- a/works/life/computer-network-experiment/Common.cpp +++ b/works/life/computer-network-experiment/Common.cpp @@ -116,7 +116,7 @@ std::string SafeReadUntil(int socket, char c, std::string &rest) { bool b = false;
for (int i = 0; i < received_number; i++) {
- if (buffer[i] == '\n') {
+ if (buffer[i] == c) {
result.append(buffer, i);
rest = std::string(buffer + i + 1, received_number - i - 1);
b = true;
diff --git a/works/life/computer-network-experiment/client.cpp b/works/life/computer-network-experiment/client.cpp index 2494bae..489948f 100644 --- a/works/life/computer-network-experiment/client.cpp +++ b/works/life/computer-network-experiment/client.cpp @@ -44,9 +44,9 @@ int Main() { name = ReadInputLine();
}
+ name.push_back(CRUT('\n'));
String name_data = ConvertCharString(name);
- SafeSend(client_socket,
- std::string_view{name_data.data(), name_data.size() + 1});
+ SafeSend(client_socket, name_data);
CloseSocket(client_socket);
return 0;
|