aboutsummaryrefslogtreecommitdiff
path: root/examples/hello/main.c
diff options
context:
space:
mode:
authorXavier Del Campo <xavier.delcampo@midokura.com>2023-11-16 12:57:27 +0100
committerXavier Del Campo <xavier.delcampo@midokura.com>2023-11-20 16:06:20 +0100
commitc9edbbc4b04ba03c3fc2c1dc7768fdfecd04fec3 (patch)
tree9e34e3f750ccb6cc6f2e2c7d14d8924c8ee56534 /examples/hello/main.c
parent98f5f52461b0c1ab1ee3331722bd32e2db9e1d41 (diff)
examples/hello: Update according to handler_loop
Diffstat (limited to 'examples/hello/main.c')
-rw-r--r--examples/hello/main.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/examples/hello/main.c b/examples/hello/main.c
index 59643ec..62e2a9e 100644
--- a/examples/hello/main.c
+++ b/examples/hello/main.c
@@ -81,7 +81,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
@@ -103,12 +102,22 @@ int main(int argc, char *argv[])
goto end;
}
- if (handler_listen(h, port))
+ unsigned short outport;
+
+ if (handler_listen(h, 0, &outport))
{
fprintf(stderr, "%s: handler_listen failed\n", __func__);
goto end;
}
+ printf("Listening on port %hu\n", outport);
+
+ if (handler_loop(h))
+ {
+ fprintf(stderr, "%s: handler_loop failed\n", __func__);
+ goto end;
+ }
+
ret = EXIT_SUCCESS;
end: