diff options
| -rw-r--r-- | src/main.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -33,18 +33,21 @@ int establish_connection(struct sockaddr_in addr) { // handles new telnet connections. // returns 0 on success and -1 on failure. -int handle_new_connection(int sfd, struct pollfd *fds, nfds_t *nfds) { +int handle_new_connection(int sfd, struct pollfd *fds, nfds_t *nfds, + struct client *clients) { int conn = accept(sfd, NULL, NULL); if (conn == -1) return -1; fds[*nfds].fd = conn; fds[*nfds].events = POLLIN; + clients[*nfds].has_nickname = 0; (*nfds)++; return 0; } // process message to all the connected clients. // returns 0 on success and -1 on failure. +// TODO: add struct client *clients int process_message(struct pollfd *fds, nfds_t *nfds) { for (nfds_t i = 1; i < *nfds; i++) { /* if client has something to say */ @@ -104,7 +107,7 @@ int main() { return 1; } if (fds[0].revents & POLLIN) { - if (handle_new_connection(sfd, fds, &nfds) == -1) { + if (handle_new_connection(sfd, fds, &nfds, clients) == -1) { perror("could not accept connection"); continue; } |
