diff options
Diffstat (limited to 'lib/include/libostp/server.h')
-rw-r--r-- | lib/include/libostp/server.h | 17 |
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_ */ |