summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c6
1 files changed, 5 insertions, 1 deletions
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 <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 */