MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / SetPort

Method SetPort

test/799.cpp:66–82  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

64 * @param port set the port number.
65 */
66void 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
84int main() {
85 NetworkAddress na("127.0.0.1", 3979);

Callers 1

NetworkAddressMethod · 0.95

Calls 2

printfFunction · 0.85
htonsFunction · 0.85

Tested by

no test coverage detected