summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-04-08 00:41:35 +0000
committerrubidium <rubidium@openttd.org>2009-04-08 00:41:35 +0000
commit20e82c46d3d983311f9d67c15adcb6e5c86ec567 (patch)
tree0730838415e1018143bfd31b6f06d6c0d295e227 /src/network
parent1eb4aa971ea329f18dd77b58bf7fc84d6240ea57 (diff)
downloadopenttd-20e82c46d3d983311f9d67c15adcb6e5c86ec567.tar.xz
(svn r15976) -Codechange: make it a bit more clear for what (type of) address binding fails
Diffstat (limited to 'src/network')
-rw-r--r--src/network/core/address.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/network/core/address.cpp b/src/network/core/address.cpp
index 6045cc98b..29391cff2 100644
--- a/src/network/core/address.cpp
+++ b/src/network/core/address.cpp
@@ -245,46 +245,46 @@ SOCKET NetworkAddress::Connect()
*/
static SOCKET ListenLoopProc(addrinfo *runp)
{
+ const char *type = runp->ai_socktype == SOCK_STREAM ? "tcp" : "udp";
+ const char *address = NetworkAddress(runp->ai_addr, runp->ai_addrlen).GetAddressAsString();
+
SOCKET sock = socket(runp->ai_family, runp->ai_socktype, runp->ai_protocol);
if (sock == INVALID_SOCKET) {
- DEBUG(net, 1, "Could not create socket: %s", strerror(errno));
+ DEBUG(net, 1, "[%s] Could not create socket on port %s: %s", type, address, strerror(errno));
return INVALID_SOCKET;
}
if (runp->ai_socktype == SOCK_STREAM && !SetNoDelay(sock)) {
- DEBUG(net, 1, "Setting TCP_NODELAY failed");
+ DEBUG(net, 1, "[%s] Setting TCP_NODELAY failed for port %s", type, address);
}
int on = 1;
/* The (const char*) cast is needed for windows!! */
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char*)&on, sizeof(on)) == -1) {
- DEBUG(net, 1, "Could not set reusable sockets: %s", strerror(errno));
+ DEBUG(net, 1, "[%s] Could not set reusable sockets for port %s: %s", type, address, strerror(errno));
}
if (runp->ai_family == AF_INET6 &&
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&on, sizeof(on)) == -1) {
- DEBUG(net, 1, "Could not disable IPv4 over IPv6: %s", strerror(errno));
+ DEBUG(net, 1, "[%s] Could not disable IPv4 over IPv6 on port %s: %s", type, address, strerror(errno));
}
if (bind(sock, runp->ai_addr, runp->ai_addrlen) != 0) {
- DEBUG(net, 1, "Could not bind: %s", strerror(errno));
+ DEBUG(net, 1, "[%s] Could not bind on port %s: %s", type, address, strerror(errno));
closesocket(sock);
return INVALID_SOCKET;
}
if (runp->ai_socktype != SOCK_DGRAM && listen(sock, 1) != 0) {
- DEBUG(net, 1, "Could not listen: %s", strerror(errno));
+ DEBUG(net, 1, "[%s] Could not listen at port %s: %s", type, address, strerror(errno));
closesocket(sock);
return INVALID_SOCKET;
}
/* Connection succeeded */
- if (!SetNonBlocking(sock)) DEBUG(net, 0, "Setting non-blocking mode failed");
-
- DEBUG(net, 1, "[%s] Listening on port %s",
- runp->ai_socktype == SOCK_STREAM ? "tcp" : "udp",
- NetworkAddress(runp->ai_addr, runp->ai_addrlen).GetAddressAsString());
+ if (!SetNonBlocking(sock)) DEBUG(net, 0, "[%s] Setting non-blocking mode failed for port %s", type, address);
+ DEBUG(net, 1, "[%s] Listening on port %s", type, address);
return sock;
}