Nodes use network order for ports.

This commit is contained in:
momo5502 2016-01-29 01:53:17 +01:00
parent 31ae9a779a
commit c83fab449a
2 changed files with 4 additions and 4 deletions

View File

@ -15,11 +15,11 @@ namespace Components
} }
void Network::Address::SetPort(unsigned short port) void Network::Address::SetPort(unsigned short port)
{ {
this->address.port = ntohs(port); this->address.port = htons(port);
}; };
unsigned short Network::Address::GetPort() unsigned short Network::Address::GetPort()
{ {
return htons(this->address.port); return ntohs(this->address.port);
} }
void Network::Address::SetIP(DWORD ip) void Network::Address::SetIP(DWORD ip)
{ {

View File

@ -60,7 +60,7 @@ namespace Components
Network::Address address; Network::Address address;
address.SetIP(this->ip); address.SetIP(this->ip);
address.SetPort(this->port); address.SetPort(ntohs(this->port));
address.SetType(Game::netadrtype_t::NA_IP); address.SetType(Game::netadrtype_t::NA_IP);
return address; return address;
@ -69,7 +69,7 @@ namespace Components
void fromNetAddress(Network::Address address) void fromNetAddress(Network::Address address)
{ {
this->ip = address.GetIP(); this->ip = address.GetIP();
this->port = address.GetPort(); this->port = htons(address.GetPort());
} }
}; };
#pragma pack(pop) #pragma pack(pop)