diff options
| author | cashmere <cashmere@autistici.org> | 2026-06-30 12:50:29 +0200 |
|---|---|---|
| committer | cashmere <cashmere@autistici.org> | 2026-06-30 12:50:29 +0200 |
| commit | ed648a83def7218a935d27e96e9e1c53a70e1239 (patch) | |
| tree | e079a1542461a525591047077b3673b152be884d /src | |
| parent | 0ebd503c15915fb7d72d28888b0d7ed050a198bd (diff) | |
| download | telnet-ed648a83def7218a935d27e96e9e1c53a70e1239.tar.gz | |
src/main.c: add function descriptions
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -5,7 +5,7 @@ #include <unistd.h> // 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 */ |
