Skip to content

Commit

Permalink
🪲 Woopsies
Browse files Browse the repository at this point in the history
  • Loading branch information
Lygaen committed Feb 29, 2024
1 parent ff025fe commit 458cb17
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/utils/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,26 @@ ClientSocket::ClientSocket(socket_t client, char *addr) : address(addr)
sock = client;
connected = true;

#if defined(__linux__)
const int flags = fcntl(sock, F_GETFL, 0);
fcntl(sock, F_SETFL, flags & ~O_NONBLOCK);
#elif defined(_WIN32)
u_long mode = 0; // 0 to disable non-blocking socket
ioctlsocket(sock, FIONBIO, &mode);
#endif
}

ClientSocket::ClientSocket(int type)
{
connected = false;

sock = socket(AF_INET, type, 0);

#if defined(__linux__)
const int flags = fcntl(sock, F_GETFL, 0);
fcntl(sock, F_SETFL, flags & ~O_NONBLOCK);
#elif defined(_WIN32)
u_long mode = 0; // 0 to disable non-blocking socket
ioctlsocket(sock, FIONBIO, &mode);
#endif
}

bool ClientSocket::connect(const char *address, int port) const
Expand Down

0 comments on commit 458cb17

Please sign in to comment.