diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -4,6 +4,11 @@ #include <sys/socket.h> #include <unistd.h> +struct client { + char nickname[32]; + int has_nickname; +}; + // returns a socket file descriptor. // if connection could not be established, -1 gets returned int establish_connection(struct sockaddr_in addr) { @@ -61,8 +66,7 @@ int process_message(struct pollfd *fds, nfds_t *nfds) { (*nfds)--; /* size down the current array */ i--; return -1; - } - else { + } else { /* send every message bytes to the other clients */ for (nfds_t j = 1; j < *nfds; j++) { if (j != i) { @@ -80,6 +84,7 @@ int main() { addr.sin_family = AF_INET; /* IPv4 */ addr.sin_port = htons(8000); /* Port */ addr.sin_addr.s_addr = INADDR_ANY; /* equals to 0.0.0.0 */ + struct client clients[256]; struct pollfd fds[256]; int sfd = establish_connection(addr); if (sfd == -1) { |
