From ed648a83def7218a935d27e96e9e1c53a70e1239 Mon Sep 17 00:00:00 2001 From: cashmere Date: Tue, 30 Jun 2026 12:50:29 +0200 Subject: src/main.c: add function descriptions --- src/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 22b5e98..103ca2d 100644 --- a/src/main.c +++ b/src/main.c @@ -5,7 +5,7 @@ #include // returns a socket file descriptor. -// if connection could not be established, 1 gets returned +// if connection could not be established, -1 gets returned int establish_connection(struct sockaddr_in addr) { int sfd = socket(AF_INET, SOCK_STREAM, 0); if (sfd == -1) { @@ -29,6 +29,8 @@ int establish_connection(struct sockaddr_in addr) { return sfd; } +// 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 conn = accept(sfd, NULL, NULL); if (conn == -1) @@ -39,6 +41,8 @@ int handle_new_connection(int sfd, struct pollfd *fds, nfds_t *nfds) { return 0; } +// process message to all the connected clients. +// returns 0 on success and -1 on failure. int process_message(struct pollfd *fds, nfds_t *nfds) { for (nfds_t i = 1; i < *nfds; i++) { /* if client has something to say */ -- cgit v1.3.1