From 6d585d3eeb25c88dbee7d77aa5b31f3eb952a940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=A9rence=20Clastres?= Date: Sat, 20 Jun 2020 13:49:59 +0200 Subject: [PATCH] Network: Print used port on startup and change default to 6742 Also print an error if server can't be started 1337 is already used by razer's rest server Port idea by @bahorn (6742 = ORGB on a phone numpad) --- NetworkClient.cpp | 2 +- NetworkServer.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NetworkClient.cpp b/NetworkClient.cpp index 32956093..c733d911 100644 --- a/NetworkClient.cpp +++ b/NetworkClient.cpp @@ -37,7 +37,7 @@ static void Sleep(unsigned int milliseconds) NetworkClient::NetworkClient(std::vector& control) : controllers(control) { strcpy(port_ip, "127.0.0.1"); - port_num = 1337; + port_num = 6742; server_connected = false; server_controller_count = 0; } diff --git a/NetworkServer.cpp b/NetworkServer.cpp index 527b0c51..5951c65f 100644 --- a/NetworkServer.cpp +++ b/NetworkServer.cpp @@ -37,7 +37,7 @@ static void Sleep(unsigned int milliseconds) NetworkServer::NetworkServer(std::vector& control) : controllers(control) { - port_num = 1337; + port_num = 6742; server_online = false; } @@ -134,6 +134,7 @@ void NetworkServer::StartServer() server_sock = socket(AF_INET, SOCK_STREAM, 0); if (server_sock == INVALID_SOCKET) { + printf("Error: network socket could not be created\n"); WSACleanup(); return; } @@ -150,6 +151,7 @@ void NetworkServer::StartServer() \*-------------------------------------------------*/ if (bind(server_sock, (sockaddr*)&myAddress, sizeof(myAddress)) == SOCKET_ERROR) { + printf("Error: Could not bind network socket \nIs port %hu already being used?\n", GetPort()); WSACleanup(); return; } @@ -200,7 +202,7 @@ void NetworkServer::ConnectionThreadFunction() { //This thread handles client connections - printf("Network connection thread started\n"); + printf("Network connection thread started on port %hu\n", GetPort()); while(server_online == true) { /*-------------------------------------------------*\