From 73ead92c2d37d5d091992ef617c4abdfe9907a18 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sun, 29 Sep 2024 22:38:43 -0400 Subject: project: Massive fixups - Fix client handling - Add multithreading - Fixup bad values Signed-off-by: Ian Moffett --- lib/include/libostp/server.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lib/include/libostp') diff --git a/lib/include/libostp/server.h b/lib/include/libostp/server.h index a7a737b..0e232f6 100644 --- a/lib/include/libostp/server.h +++ b/lib/include/libostp/server.h @@ -32,23 +32,32 @@ #include #include +#include #include #define MAX_CLIENTS 32 +struct ostp_client { + struct ostp_session session; + int sockfd; + pthread_t td; +}; + struct ostp_listener { - int(*on_recv)(struct ostp_session *session, const char *buf, size_t len); + int(*on_recv)(struct ostp_client *c, const char *buf, size_t len); int port; /* -- Private -- */ - int clients[MAX_CLIENTS]; + struct ostp_client clients[MAX_CLIENTS]; + size_t client_count; int serv_sockfd; fd_set client_fds; }; void listener_init(struct ostp_listener *lp); -int listener_bind(struct ostp_session *sp, struct ostp_listener *lp); -int listener_poll(struct ostp_session *sp, struct ostp_listener *lp); +int listener_bind(struct ostp_listener *lp); +int listener_poll(struct ostp_listener *lp); void listener_cleanup(struct ostp_listener *lp); +void listener_close(struct ostp_listener *lp, struct ostp_client *c); #endif /* !LIBOSTP_SERVER_H_ */ -- cgit v1.2.3