MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SetPort

Method SetPort

src/network/core/address.cpp:58–73  ·  view source on GitHub ↗

* Set the port. * @param port set the port number. */

Source from the content-addressed store, hash-verified

56 * @param port set the port number.
57 */
58void NetworkAddress::SetPort(uint16_t port)
59{
60 switch (this->address.ss_family) {
61 case AF_UNSPEC:
62 case AF_INET:
63 ((struct sockaddr_in*)&this->address)->sin_port = htons(port);
64 break;
65
66 case AF_INET6:
67 ((struct sockaddr_in6*)&this->address)->sin6_port = htons(port);
68 break;
69
70 default:
71 NOT_REACHED();
72 }
73}
74
75/**
76 * Helper to get the formatting string of an address for a given family.

Callers 2

NetworkAddressMethod · 0.95
NetworkFindBroadcastIPsFunction · 0.80

Calls 1

NOT_REACHEDFunction · 0.85

Tested by

no test coverage detected