mirror of https://github.com/OpenTTD/OpenTTD
(svn r15972) -Codechange: remove unneeded parameter
parent
2a6e9288fd
commit
c0f8214218
|
@ -162,13 +162,13 @@ SOCKET NetworkAddress::Resolve(int family, int socktype, int flags, SocketList *
|
||||||
/* Setting both hostname to NULL and port to 0 is not allowed.
|
/* Setting both hostname to NULL and port to 0 is not allowed.
|
||||||
* As port 0 means bind to any port, the other must mean that
|
* As port 0 means bind to any port, the other must mean that
|
||||||
* we want to bind to 'all' IPs. */
|
* we want to bind to 'all' IPs. */
|
||||||
if (this->address_length == 0 && StrEmpty(this->hostname)) {
|
if (this->address_length == 0 && this->GetPort() == 0) {
|
||||||
strecpy(this->hostname, this->address.ss_family == AF_INET ? "0.0.0.0" : "::", lastof(this->hostname));
|
strecpy(this->hostname, this->address.ss_family == AF_INET ? "0.0.0.0" : "::", lastof(this->hostname));
|
||||||
}
|
}
|
||||||
|
|
||||||
int e = getaddrinfo(this->GetHostname(), port_name, &hints, &ai);
|
int e = getaddrinfo(StrEmpty(this->hostname) ? NULL : this->hostname, port_name, &hints, &ai);
|
||||||
if (e != 0) {
|
if (e != 0) {
|
||||||
DEBUG(net, 0, "getaddrinfo(%s, %s) failed: %s", this->GetHostname(), port_name, FS2OTTD(gai_strerror(e)));
|
DEBUG(net, 0, "getaddrinfo(%s, %s) failed: %s", this->hostname, port_name, FS2OTTD(gai_strerror(e)));
|
||||||
return INVALID_SOCKET;
|
return INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,12 +270,16 @@ static SOCKET ListenLoopProc(addrinfo *runp)
|
||||||
/* Connection succeeded */
|
/* Connection succeeded */
|
||||||
if (!SetNonBlocking(sock)) DEBUG(net, 0, "Setting non-blocking mode failed");
|
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());
|
||||||
|
|
||||||
return sock;
|
return sock;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOCKET NetworkAddress::Listen(int family, int socktype, SocketList *sockets)
|
SOCKET NetworkAddress::Listen(int socktype, SocketList *sockets)
|
||||||
{
|
{
|
||||||
return this->Resolve(family, socktype, AI_ADDRCONFIG | AI_PASSIVE, sockets, ListenLoopProc);
|
return this->Resolve(AF_UNSPEC, socktype, AI_ADDRCONFIG | AI_PASSIVE, sockets, ListenLoopProc);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
|
|
@ -217,12 +217,11 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make the given socket listen.
|
* Make the given socket listen.
|
||||||
* @param family the type of 'protocol' (IPv4, IPv6)
|
|
||||||
* @param socktype the type of socket (TCP, UDP, etc)
|
* @param socktype the type of socket (TCP, UDP, etc)
|
||||||
* @param sockets the list of sockets to add the sockets to
|
* @param sockets the list of sockets to add the sockets to
|
||||||
* @return the socket (if sockets != NULL)
|
* @return the socket (if sockets != NULL)
|
||||||
*/
|
*/
|
||||||
SOCKET Listen(int family, int socktype, SocketList *sockets = NULL);
|
SOCKET Listen(int socktype, SocketList *sockets = NULL);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
|
|
@ -41,11 +41,7 @@ bool NetworkUDPSocketHandler::Listen()
|
||||||
this->Close();
|
this->Close();
|
||||||
|
|
||||||
for (NetworkAddress *addr = this->bind.Begin(); addr != this->bind.End(); addr++) {
|
for (NetworkAddress *addr = this->bind.Begin(); addr != this->bind.End(); addr++) {
|
||||||
addr->Listen(AF_UNSPEC, SOCK_DGRAM, &this->sockets);
|
addr->Listen(SOCK_DGRAM, &this->sockets);
|
||||||
}
|
|
||||||
|
|
||||||
for (SocketList::iterator s = this->sockets.Begin(); s != this->sockets.End(); s++) {
|
|
||||||
DEBUG(net, 1, "[udp] listening on port %s", s->first.GetAddressAsString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this->sockets.Length() != 0;
|
return this->sockets.Length() != 0;
|
||||||
|
|
|
@ -539,7 +539,7 @@ static bool NetworkListen()
|
||||||
|
|
||||||
DEBUG(net, 1, "Listening on %s", address.GetAddressAsString());
|
DEBUG(net, 1, "Listening on %s", address.GetAddressAsString());
|
||||||
|
|
||||||
SOCKET ls = address.Listen(AF_INET, SOCK_STREAM);
|
SOCKET ls = address.Listen(SOCK_STREAM);
|
||||||
if (ls == INVALID_SOCKET) {
|
if (ls == INVALID_SOCKET) {
|
||||||
ServerStartError("Could not create listening socket");
|
ServerStartError("Could not create listening socket");
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue