* Set the port. * @param port set the port number. */
| 56 | * @param port set the port number. |
| 57 | */ |
| 58 | void 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. |
no test coverage detected