diff options
author | crupest <crupest@outlook.com> | 2021-06-06 23:43:52 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-06-06 23:43:52 +0800 |
commit | 7a269e185fc59e5f81e7c91e6e75891ba2ca4b3b (patch) | |
tree | 8a0baf8e5eac69003770306e7968c1196a5a49dd /works/life/computer-network-experiment/Common.cpp | |
parent | fcd2304e04dd3fabdefce4293b1b76ad99f8ed73 (diff) | |
download | crupest-7a269e185fc59e5f81e7c91e6e75891ba2ca4b3b.tar.gz crupest-7a269e185fc59e5f81e7c91e6e75891ba2ca4b3b.tar.bz2 crupest-7a269e185fc59e5f81e7c91e6e75891ba2ca4b3b.zip |
import(life): ...
Diffstat (limited to 'works/life/computer-network-experiment/Common.cpp')
-rw-r--r-- | works/life/computer-network-experiment/Common.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/works/life/computer-network-experiment/Common.cpp b/works/life/computer-network-experiment/Common.cpp index 2e01dcb..59c2f0f 100644 --- a/works/life/computer-network-experiment/Common.cpp +++ b/works/life/computer-network-experiment/Common.cpp @@ -5,6 +5,11 @@ #ifdef WIN32
#include <Windows.h>
#include <winsock.h>
+#else
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <sys/unistd.h>
#endif
[[noreturn]] void PrintErrorMessageAndExit(StringView message,
@@ -46,6 +51,14 @@ void InitWSA() { }
#endif
+int Close(int socket) {
+#ifdef WIN32
+ return closesocket(socket);
+#else
+ return close(socket);
+#endif
+}
+
int main() {
#ifdef WIN32
InitWSA();
|