Fix inconsistencies with handling errors in early network startup

In most cases, when socket creation, bind, listen, or similar fails,
it's best to gracefully shutdown. We do that now.
This commit is contained in:
Lion Kortlepel
2022-03-24 14:05:40 +01:00
parent 4cb299061e
commit dbfe4a4d11
3 changed files with 40 additions and 26 deletions

View File

@@ -6,10 +6,10 @@
#ifdef BEAMMP_LINUX
#include <arpa/inet.h>
#include <errno.h>
#include <sys/socket.h>
#include <termios.h>
#include <unistd.h>
#include <errno.h>
using SOCKET = int;
using DWORD = unsigned long;
using PDWORD = unsigned long*;
@@ -25,10 +25,10 @@ inline void CloseSocketProper(int TheSocket) {
#ifdef BEAMMP_APPLE
#include <arpa/inet.h>
#include <errno.h>
#include <sys/socket.h>
#include <termios.h>
#include <unistd.h>
#include <errno.h>
using SOCKET = int;
using DWORD = unsigned long;
using PDWORD = unsigned long*;
@@ -48,6 +48,11 @@ inline void CloseSocketProper(int TheSocket) {
inline void CloseSocketProper(SOCKET TheSocket) {
shutdown(TheSocket, 2); // 2 == SD_BOTH
closesocket(TheSocket);
}
#endif // WIN32
#ifdef INVALID_SOCKET
static inline constexpr int BEAMMP_INVALID_SOCKET = INVALID_SOCKET;
#else
static inline constexpr int BEAMMP_INVALID_SOCKET = -1;
#endif