aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/headers/main.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/examples/headers/main.c b/examples/headers/main.c
index b465aa1..51d622a 100644
--- a/examples/headers/main.c
+++ b/examples/headers/main.c
@@ -44,7 +44,6 @@ static int on_length(const unsigned long long len,
int main(int argc, char *argv[])
{
int ret = EXIT_FAILURE;
- const short port = 8080;
const struct handler_cfg cfg =
{
.length = on_length,
@@ -67,12 +66,22 @@ int main(int argc, char *argv[])
goto end;
}
- if (handler_listen(h, port))
+ unsigned short port;
+
+ if (handler_listen(h, 0, &port))
{
fprintf(stderr, "%s: handler_listen failed\n", __func__);
goto end;
}
+ printf("Listening on port %hu\n", port);
+
+ if (handler_loop(h))
+ {
+ fprintf(stderr, "%s: handler_loop failed\n", __func__);
+ goto end;
+ }
+
ret = EXIT_SUCCESS;
end: