aboutsummaryrefslogtreecommitdiff
path: root/examples/headers
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-11-20 17:05:21 +0100
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-11-20 17:05:21 +0100
commitbc1d77983acd0e5160071fb724fef90ac0f9ca37 (patch)
tree19e7d3ead9fc9e8c016a5dc0f1e3a984eed78679 /examples/headers
parentb94f76033f72d4eba629a6473a2b301dd7988f97 (diff)
headers/main.c: Update to new handler interface
Diffstat (limited to 'examples/headers')
-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: