aboutsummaryrefslogtreecommitdiff
path: root/lib/include/libostp/server.h
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-09-29 22:38:43 -0400
committerIan Moffett <ian@osmora.org>2024-09-29 22:38:43 -0400
commit73ead92c2d37d5d091992ef617c4abdfe9907a18 (patch)
tree1b689727607d72e525cee5bd298367aadc293615 /lib/include/libostp/server.h
parent788b1308e86320882245159540ef0a489209bcf1 (diff)
project: Massive fixups
- Fix client handling - Add multithreading - Fixup bad values Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/include/libostp/server.h')
-rw-r--r--lib/include/libostp/server.h17
1 files changed, 13 insertions, 4 deletions
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 <sys/select.h>
#include <libostp/session.h>
+#include <pthread.h>
#include <stddef.h>
#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_ */