diff options
| author | xavi <xavi@noreply.localhost> | 2023-11-20 16:24:15 +0100 |
|---|---|---|
| committer | xavi <xavi@noreply.localhost> | 2023-11-20 16:24:15 +0100 |
| commit | 44676b84fd9aa689e4abbb588bead19a36061fa1 (patch) | |
| tree | 388e86e26531b1b6612e0a178fbd29cd89c86814 /server.c | |
| parent | 65031ca3502e0c27780be847fd97c112546741a9 (diff) | |
| parent | 2561ec32fe24e9cc81151193fbf2c55c94078816 (diff) | |
Merge pull request 'Allow `listen_port` to return selected port number' (#1) from midokura-xavi/libweb:listen-port into master
Reviewed-on: https://gitea.privatedns.org/xavi/libweb/pulls/1
Diffstat (limited to 'server.c')
| -rw-r--r-- | server.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -320,7 +320,8 @@ static int init_signals(void) return 0; } -struct server *server_init(const unsigned short port) +struct server *server_init(const unsigned short port, + unsigned short *const outport) { struct server *const s = malloc(sizeof *s); @@ -373,8 +374,9 @@ struct server *server_init(const unsigned short port) fprintf(stderr, "%s: getsockname(2): %s\n", __func__, strerror(errno)); goto failure; } + else if (outport) + *outport = ntohs(in.sin_port); - printf("Listening on port %hu\n", ntohs(in.sin_port)); return s; failure: |
