aboutsummaryrefslogtreecommitdiff
path: root/works/life/computer-network-experiment/Common.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'works/life/computer-network-experiment/Common.cpp')
-rw-r--r--works/life/computer-network-experiment/Common.cpp13
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();