(svn r15921) -Fix: some OSes don't like sizeof(sockaddr_storage) but want sizeof(sockaddr) or whatever is 'valid' for the given protocol

This commit is contained in:
rubidium
2009-04-03 00:33:00 +00:00
parent c7b6469dab
commit ba5aafb9bb
4 changed files with 36 additions and 25 deletions

View File

@@ -1090,24 +1090,15 @@ static void NetworkGenerateUniqueId()
void NetworkStartDebugLog(NetworkAddress address)
{
extern SOCKET _debug_socket; // Comes from debug.c
SOCKET s;
DEBUG(net, 0, "Redirecting DEBUG() to %s:%d", address.GetHostname(), address.GetPort());
s = socket(AF_INET, SOCK_STREAM, 0);
SOCKET s = address.Connect();
if (s == INVALID_SOCKET) {
DEBUG(net, 0, "Failed to open socket for redirection DEBUG()");
return;
}
if (!SetNoDelay(s)) DEBUG(net, 1, "Setting TCP_NODELAY failed");
if (connect(s, (struct sockaddr *)address.GetAddress(), sizeof(*address.GetAddress())) != 0) {
DEBUG(net, 0, "Failed to redirection DEBUG() to %s", address.GetAddressAsString());
return;
}
if (!SetNonBlocking(s)) DEBUG(net, 0, "Setting non-blocking mode failed");
_debug_socket = s;
DEBUG(net, 0, "DEBUG() is now redirected");