Revert broken IPv6 code on Windows
This commit is contained in:
parent
4fdda85cbd
commit
9868f77c0d
|
@ -11,7 +11,7 @@ char gGetHostName[MAX_CONFIG_STRING] = "";
|
||||||
|
|
||||||
void resolve_domain(void) {
|
void resolve_domain(void) {
|
||||||
struct hostent *remoteHost = gethostbyname(configJoinIp);
|
struct hostent *remoteHost = gethostbyname(configJoinIp);
|
||||||
if (remoteHost && (remoteHost->h_addrtype == AF_INET || remoteHost->h_addrtype == AF_INET6)) {
|
if (remoteHost && remoteHost->h_addrtype == AF_INET) {
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
for (int i = 0; remoteHost->h_addr_list[i] != 0; i++) {
|
for (int i = 0; remoteHost->h_addr_list[i] != 0; i++) {
|
||||||
memcpy(&addr, remoteHost->h_addr_list[i], sizeof(struct in_addr));
|
memcpy(&addr, remoteHost->h_addr_list[i], sizeof(struct in_addr));
|
||||||
|
@ -22,11 +22,7 @@ void resolve_domain(void) {
|
||||||
|
|
||||||
static int socket_bind(SOCKET socket, unsigned int port) {
|
static int socket_bind(SOCKET socket, unsigned int port) {
|
||||||
struct sockaddr_in rxAddr;
|
struct sockaddr_in rxAddr;
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
|
||||||
rxAddr.sin_family = AF_INET6;
|
|
||||||
#else
|
|
||||||
rxAddr.sin_family = AF_INET;
|
rxAddr.sin_family = AF_INET;
|
||||||
#endif
|
|
||||||
rxAddr.sin_port = htons(port);
|
rxAddr.sin_port = htons(port);
|
||||||
rxAddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
rxAddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||||
|
|
||||||
|
@ -103,12 +99,7 @@ static bool ns_socket_initialize(enum NetworkType networkType, UNUSED bool recon
|
||||||
LOG_INFO("bound to port %u", port);
|
LOG_INFO("bound to port %u", port);
|
||||||
} else {
|
} else {
|
||||||
// save the port to send to
|
// save the port to send to
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
|
||||||
sAddr[0].sin_family = AF_INET6;
|
|
||||||
#else
|
|
||||||
sAddr[0].sin_family = AF_INET;
|
sAddr[0].sin_family = AF_INET;
|
||||||
#endif
|
|
||||||
|
|
||||||
sAddr[0].sin_port = htons(port);
|
sAddr[0].sin_port = htons(port);
|
||||||
resolve_domain();
|
resolve_domain();
|
||||||
sAddr[0].sin_addr.s_addr = inet_addr(configJoinIp);
|
sAddr[0].sin_addr.s_addr = inet_addr(configJoinIp);
|
||||||
|
|
|
@ -13,7 +13,7 @@ SOCKET socket_initialize(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize socket
|
// initialize socket
|
||||||
SOCKET sock = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
|
SOCKET sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||||
if (sock == INVALID_SOCKET) {
|
if (sock == INVALID_SOCKET) {
|
||||||
LOG_ERROR("socket failed with error %d", SOCKET_LAST_ERROR);
|
LOG_ERROR("socket failed with error %d", SOCKET_LAST_ERROR);
|
||||||
return INVALID_SOCKET;
|
return INVALID_SOCKET;
|
||||||
|
@ -27,14 +27,6 @@ SOCKET socket_initialize(void) {
|
||||||
return INVALID_SOCKET;
|
return INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure our socket is dual-stack. So we can use both IPv4 and IPv6.
|
|
||||||
int opt = 0;
|
|
||||||
rc = setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&opt, sizeof(opt));
|
|
||||||
if (rc != NO_ERROR) {
|
|
||||||
LOG_ERROR("setsockopt(IPV6_V6ONLY) failed with error: %d", rc);
|
|
||||||
return INVALID_SOCKET;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if MAX_PLAYERS > 4
|
#if MAX_PLAYERS > 4
|
||||||
// on windows, the send buffer for the socket needs to be increased
|
// on windows, the send buffer for the socket needs to be increased
|
||||||
// for the many players case to avoid WSAEWOULDBLOCK on send
|
// for the many players case to avoid WSAEWOULDBLOCK on send
|
||||||
|
|
Loading…
Reference in New Issue