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 | fcd2304e04dd3fabdefce4293b1b76ad99f8ed73 (patch) | |
tree | ee19cca7bfc1f66590d499a2b40d0e5c8b1d0d00 /works/life/computer-network-experiment/server.cpp | |
parent | f0309ee1e5cd268091f59f3aa377beca77d76c5c (diff) | |
download | crupest-fcd2304e04dd3fabdefce4293b1b76ad99f8ed73.tar.gz crupest-fcd2304e04dd3fabdefce4293b1b76ad99f8ed73.tar.bz2 crupest-fcd2304e04dd3fabdefce4293b1b76ad99f8ed73.zip |
import(life): ...
Diffstat (limited to 'works/life/computer-network-experiment/server.cpp')
-rw-r--r-- | works/life/computer-network-experiment/server.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/works/life/computer-network-experiment/server.cpp b/works/life/computer-network-experiment/server.cpp index 297114b..9cf655a 100644 --- a/works/life/computer-network-experiment/server.cpp +++ b/works/life/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) {
|