libweb/doc/man3/handler_listen.3

57 lines
1.4 KiB
Groff

.TH HANDLER_LISTEN 3 2024-02-19 0.3.0 "libweb Library Reference"
.SH NAME
handler_listen \- initialize server to listen to a given port
.SH SYNOPSIS
.LP
.nf
#include <libweb/handler.h>
.P
int handler_listen(struct handler *\fIh\fP, unsigned short \fIport\fP, unsigned short *\fIoutport\fP);
.fi
.SH DESCRIPTION
The
.IR handler_listen (3)
function initializes the internal server on a
.I struct handler
object pointed to by
.IR h ,
which must be previously allocated by a call to
.IR handler_alloc (3),
to listen on the TCP port given by
.IR port .
If
.I outport
is a valid pointer,
.IR handler_listen (3)
shall assign the object pointed to by
.I outport
to the port number the server shall listen to. This is typically meant
for servers that listen on any port, but the caller needs to know which
port was eventually selected by the implementation.
.SH RETURN VALUE
On success, zero is returned. On error, a negative integer is returned.
.SH ERRORS
No errors are defined.
.SH SEE ALSO
.BR handler_alloc (3),
.BR handler_free (3),
.BR handler_add (3),
.BR handler_loop (3),
.BR libweb_handler (7),
.BR signal (7).
.SH COPYRIGHT
Copyright (C) 2023-2024 libweb contributors
.P
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.