diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp --- a/src/network/core/udp.cpp +++ b/src/network/core/udp.cpp @@ -59,7 +59,7 @@ bool NetworkUDPSocketHandler::Listen() void NetworkUDPSocketHandler::CloseSocket() { for (auto &s : this->sockets) { - closesocket(s.second); + closesocket(s.first); } this->sockets.clear(); } @@ -81,20 +81,20 @@ void NetworkUDPSocketHandler::SendPacket NetworkAddress send(*recv); /* Not the same type */ - if (!send.IsFamily(s.first.GetAddress()->ss_family)) continue; + if (!send.IsFamily(s.second.GetAddress()->ss_family)) continue; p->PrepareToSend(); if (broadcast) { /* Enable broadcast */ unsigned long val = 1; - if (setsockopt(s.second, SOL_SOCKET, SO_BROADCAST, (char *) &val, sizeof(val)) < 0) { + if (setsockopt(s.first, SOL_SOCKET, SO_BROADCAST, (char *) &val, sizeof(val)) < 0) { Debug(net, 1, "Setting broadcast mode failed: {}", NetworkError::GetLast().AsString()); } } /* Send the buffer */ - ssize_t res = p->TransferOut(sendto, s.second, 0, (const struct sockaddr *)send.GetAddress(), send.GetAddressLength()); + ssize_t res = p->TransferOut(sendto, s.first, 0, (const struct sockaddr *)send.GetAddress(), send.GetAddressLength()); Debug(net, 7, "sendto({})", send.GetAddressAsString()); /* Check for any errors, but ignore it otherwise */ @@ -119,8 +119,8 @@ void NetworkUDPSocketHandler::ReceivePac socklen_t client_len = sizeof(client_addr); /* Try to receive anything */ - SetNonBlocking(s.second); // Some OSes seem to lose the non-blocking status of the socket - ssize_t nbytes = p.TransferIn(recvfrom, s.second, 0, (struct sockaddr *)&client_addr, &client_len); + SetNonBlocking(s.first); // Some OSes seem to lose the non-blocking status of the socket + ssize_t nbytes = p.TransferIn(recvfrom, s.first, 0, (struct sockaddr *)&client_addr, &client_len); /* Did we get the bytes for the base header of the packet? */ if (nbytes <= 0) break; // No data, i.e. no packet