Skip to content

Commit 556af04

Browse files
net: change initnet, stub socketpoll
1 parent 386baa9 commit 556af04

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

game/src/net/net.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,10 @@ Net::Net() {
9898
default:
9999
if (r)
100100
throw std::runtime_error(std::string("wsa: winsock error code ") + std::to_string(r));
101+
else
102+
++initnet;
101103
break;
102104
}
103-
104-
unsigned v = ++initnet;
105-
(void)v;// printf("%s: initnet=%u\n", __func__, v);
106105
}
107106

108107
Net::~Net() {
@@ -114,13 +113,22 @@ Net::~Net() {
114113
r = WSAGetLastError();
115114

116115
switch (r) {
117-
case WSANOTINITIALISED: fprintf(stderr, "%s: winsock not initialised\n", __func__); break;
118-
case WSAENETDOWN: fprintf(stderr, "%s: winsock failed\n", __func__); break;
119-
case WSAEINPROGRESS: fprintf(stderr, "%s: winsock is blocked\n", __func__); break;
116+
case WSANOTINITIALISED:
117+
fprintf(stderr, "%s: winsock not initialised\n", __func__);
118+
break;
119+
case WSAENETDOWN:
120+
fprintf(stderr, "%s: winsock failed\n", __func__);
121+
break;
122+
case WSAEINPROGRESS:
123+
fprintf(stderr, "%s: winsock is blocked\n", __func__);
124+
break;
125+
default:
126+
if (r)
127+
fprintf(stderr, "%s: winsock error %d\n", __func__, r);
128+
else
129+
--initnet;
130+
break;
120131
}
121-
122-
unsigned v = --initnet;
123-
(void)v;// printf("%s: initnet=%u\n", __func__, v);
124132
}
125133

126134
TcpSocket::TcpSocket() : s((int)INVALID_SOCKET) {

game/src/net/net.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
// use lowercase header names as we may be cross compiling on a filesystem where filenames are case-sensitive (which is typical on e.g. linux)
2020
#include <winsock2.h>
2121

22+
#include <ws2tcpip.h>
23+
#include <windows.h>
24+
2225
#include <wepoll.h>
2326
#else
2427
#include <sys/socket.h>

game/tests/net.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ TEST(Net, StartTwice) {
4141
}
4242

4343
#if _WIN32
44+
TEST(Net, SocketPoll) {
45+
46+
}
47+
4448
TEST(Net, Adapters) {
4549
DWORD ret = 0;
4650

0 commit comments

Comments
 (0)