diff --git a/CMakeLists.txt b/CMakeLists.txt index 2454875280..310a515116 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,9 +139,6 @@ add_subdirectory(third-party/imgui) # build the game code in C++ add_subdirectory(game) -# build asio library -include_directories(third-party/asio/asio/include) - # build the compiler add_subdirectory(goalc) diff --git a/common/cross_sockets/XSocket.cpp b/common/cross_sockets/XSocket.cpp index be31cdb5b1..a65f7077e9 100644 --- a/common/cross_sockets/XSocket.cpp +++ b/common/cross_sockets/XSocket.cpp @@ -34,8 +34,14 @@ int open_socket(int af, int type, int protocol) { #endif } -int accept_socket(int socket, sockaddr* addr, int* addrLen) { +#ifdef __linux +int accept_socket(int socket, sockaddr* addr, socklen_t* addrLen) { + return accept(socket, addr, addrLen); +} +#endif + #ifdef _WIN32 +int accept_socket(int socket, sockaddr* addr, int* addrLen) { WSADATA wsaData = {0}; int iResult = 0; // Initialize Winsock @@ -44,9 +50,9 @@ int accept_socket(int socket, sockaddr* addr, int* addrLen) { printf("WSAStartup failed: %d\n", iResult); return 1; } -#endif return accept(socket, addr, addrLen); } +#endif void close_socket(int sock) { if (sock < 0) { @@ -93,7 +99,7 @@ int set_socket_timeout(int socket, long microSeconds) { } int write_to_socket(int socket, const char* buf, int len) { - int bytes_wrote; + int bytes_wrote = 0; #ifdef __linux bytes_wrote = write(socket, buf, len); #elif _WIN32 @@ -106,13 +112,11 @@ int write_to_socket(int socket, const char* buf, int len) { } int read_from_socket(int socket, char* buf, int len) { - int bytes_read; #ifdef __linux - bytes_read = read(socket, buf, len); + return read(socket, buf, len); #elif _WIN32 - bytes_read = recv(socket, buf, len, 0); + return recv(socket, buf, len, 0); #endif - return bytes_read; } bool socket_timed_out() { diff --git a/common/cross_sockets/XSocket.h b/common/cross_sockets/XSocket.h index bd18776be7..f277e9bd3b 100644 --- a/common/cross_sockets/XSocket.h +++ b/common/cross_sockets/XSocket.h @@ -1,7 +1,7 @@ #pragma once /*! - * @file xsocket.h + * @file XSocket.h * Cross platform socket library used for the listener. */ @@ -24,7 +24,11 @@ const int TCP_SOCKET_LEVEL = IPPROTO_TCP; #endif int open_socket(int af, int type, int protocol); +#ifdef __linux +int accept_socket(int socket, sockaddr* addr, socklen_t* addrLen); +#elif _WIN32 int accept_socket(int socket, sockaddr* addr, int* addrLen); +#endif void close_socket(int sock); int set_socket_option(int socket, int level, int optname, const void* optval, int optlen); int set_socket_timeout(int socket, long microSeconds); diff --git a/goalc/listener/Listener.cpp b/goalc/listener/Listener.cpp index 8f89db149d..27a8b7e9b3 100644 --- a/goalc/listener/Listener.cpp +++ b/goalc/listener/Listener.cpp @@ -18,7 +18,7 @@ #undef max #endif -#include "common/cross_sockets/xsocket.h" +#include "common/cross_sockets/XSocket.h" #include #include