Mercurial > hg > openttd
changeset 11572:e65b8d1e5c99 draft
(svn r15941) -Codechange: jonty-comp's wish partly implemented (content server) ;)
author | rubidium <rubidium@openttd.org> |
---|---|
date | Fri, 03 Apr 2009 17:20:57 +0000 |
parents | f4dcf759a3be |
children | 80782427eaa0 |
files | src/network/core/address.cpp src/network/core/address.h src/network/network_content.cpp |
diffstat | 3 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/network/core/address.cpp +++ b/src/network/core/address.cpp @@ -27,9 +27,13 @@ uint16 NetworkAddress::GetPort() const { switch (this->address.ss_family) { + case AF_UNSPEC: case AF_INET: return ntohs(((struct sockaddr_in *)&this->address)->sin_port); + case AF_INET6: + return ntohs(((struct sockaddr_in6 *)&this->address)->sin6_port); + default: NOT_REACHED(); } @@ -38,10 +42,15 @@ void NetworkAddress::SetPort(uint16 port) { switch (this->address.ss_family) { + case AF_UNSPEC: case AF_INET: ((struct sockaddr_in*)&this->address)->sin_port = htons(port); break; + case AF_INET6: + ((struct sockaddr_in6*)&this->address)->sin6_port = htons(port); + break; + default: NOT_REACHED(); }
--- a/src/network/core/address.h +++ b/src/network/core/address.h @@ -79,13 +79,14 @@ * Create a network address based on a unresolved host and port * @param ip the unresolved hostname * @param port the port + * @param family the address family */ - NetworkAddress(const char *hostname = "0.0.0.0", uint16 port = 0) : + NetworkAddress(const char *hostname = "0.0.0.0", uint16 port = 0, int family = AF_INET) : hostname(strdup(hostname)), address_length(0) { memset(&this->address, 0, sizeof(this->address)); - this->address.ss_family = AF_INET; + this->address.ss_family = family; this->SetPort(port); }
--- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -471,7 +471,7 @@ if (this->sock != INVALID_SOCKET || this->isConnecting) return; this->isConnecting = true; - new NetworkContentConnecter(NetworkAddress(NETWORK_CONTENT_SERVER_HOST, NETWORK_CONTENT_SERVER_PORT)); + new NetworkContentConnecter(NetworkAddress(NETWORK_CONTENT_SERVER_HOST, NETWORK_CONTENT_SERVER_PORT, AF_UNSPEC)); } /**