diff options
author | crupest <crupest@outlook.com> | 2021-06-06 22:13:43 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-06-06 22:13:43 +0800 |
commit | a6088689ec605c97b846fb52beadc0de89fccf76 (patch) | |
tree | 43f2f4b328a0750ee7f56df13e7c340ea67dd49b /computer-network-experiment/server.cpp | |
parent | 27f3043a55e97c13eb586cf71a3d50cf48f67aca (diff) | |
download | life-a6088689ec605c97b846fb52beadc0de89fccf76.tar.gz life-a6088689ec605c97b846fb52beadc0de89fccf76.tar.bz2 life-a6088689ec605c97b846fb52beadc0de89fccf76.zip |
...
Diffstat (limited to 'computer-network-experiment/server.cpp')
-rw-r--r-- | computer-network-experiment/server.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/computer-network-experiment/server.cpp b/computer-network-experiment/server.cpp index 297114b..9cf655a 100644 --- a/computer-network-experiment/server.cpp +++ b/computer-network-experiment/server.cpp @@ -2,15 +2,17 @@ * This is the server program.
*/
+#include "Common.h"
#include "Output.h"
-#include <cstdlib>
-#include <iostream>
#include <optional>
-#include <string>
-#include <string_view>
#include <thread>
+#ifdef WIN32
+#include <Windows.h>
+#include <winsock.h>
+#endif
+
const auto bind_address = "127.0.0.1"; // control bind address
const u_short port = 1234; // control bind port
@@ -48,11 +50,7 @@ void ResponseThreadProc(int socket, sockaddr_in address) { closesocket(socket);
}
-int main() {
-#ifdef WIN32
- InitWSA();
-#endif
-
+int Main() {
int server_socket;
if ((server_socket = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
|