diff options
author | Ian Moffett <ian@osmora.org> | 2024-09-29 18:26:07 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-09-29 18:26:07 -0400 |
commit | 6107a37ae0f8ad89ab6d2d36f93cc0d47f8bb47a (patch) | |
tree | f9172d51fb8a36b934843610cdc9a38cbbfc52da /ostp.d/init | |
parent | 8e470bc3663da4a5bbb771a4a6fbaf8a4cae224d (diff) |
project: Move server/client code into library
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'ostp.d/init')
-rw-r--r-- | ostp.d/init/main.c (renamed from ostp.d/init/otd_init.c) | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/ostp.d/init/otd_init.c b/ostp.d/init/main.c index 4b899b4..08e020e 100644 --- a/ostp.d/init/otd_init.c +++ b/ostp.d/init/main.c @@ -27,11 +27,34 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <net/listen.h> +#include <libostp/session.h> +#include <libostp/server.h> +#include <string.h> #include <stdio.h> +static int +blah(struct ostp_session *s, const char *buf, size_t len) +{ + printf("Got data!\n"); + return 0; +} + int main(void) { - return net_listen(); + struct ostp_listener l; + struct ostp_session s; + int error; + + listener_init(&l); + l.on_recv = blah; + + if ((error = listener_bind(&s, &l)) < 0) { + return error; + } + if ((error = listener_poll(&s, &l)) < 0) { + return error; + } + + return 0; } |