* Set the port. * @param port set the port number. */
| 64 | * @param port set the port number. |
| 65 | */ |
| 66 | void NetworkAddress::SetPort(uint16 port) |
| 67 | { |
| 68 | printf("Set PORT family: %d, port: %d\n", this->address.ss_family, port); |
| 69 | switch (this->address.ss_family) { |
| 70 | case AF_UNSPEC: |
| 71 | case AF_INET: |
| 72 | ((struct sockaddr_in*)&this->address)->sin_port = htons(port); |
| 73 | break; |
| 74 | |
| 75 | case AF_INET6: |
| 76 | ((struct sockaddr_in6*)&this->address)->sin6_port = htons(port); |
| 77 | break; |
| 78 | |
| 79 | default: |
| 80 | throw 0; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | int main() { |
| 85 | NetworkAddress na("127.0.0.1", 3979); |
no test coverage detected