(svn r15916) -Codechange: let the network game list use NetworkAddress
This commit is contained in:
@@ -14,7 +14,9 @@
|
||||
const char *NetworkAddress::GetHostname()
|
||||
{
|
||||
if (this->hostname == NULL) {
|
||||
this->hostname = strdup(inet_ntoa(((struct sockaddr_in *)&this->address)->sin_addr));
|
||||
char buf[NETWORK_HOSTNAME_LENGTH] = { '\0' };
|
||||
getnameinfo((struct sockaddr *)&this->address, sizeof(this->address), buf, sizeof(buf), NULL, 0, NI_NUMERICHOST);
|
||||
this->hostname = strdup(buf);
|
||||
}
|
||||
return this->hostname;
|
||||
}
|
||||
@@ -41,6 +43,18 @@ uint16 NetworkAddress::GetPort() const
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkAddress::SetPort(uint16 port)
|
||||
{
|
||||
switch (this->address.ss_family) {
|
||||
case AF_INET:
|
||||
((struct sockaddr_in*)&this->address)->sin_port = htons(port);
|
||||
break;
|
||||
|
||||
default:
|
||||
NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
const char *NetworkAddress::GetAddressAsString()
|
||||
{
|
||||
/* 6 = for the : and 5 for the decimal port number */
|
||||
|
Reference in New Issue
Block a user