summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcashmere <cashmere@autistici.org>2026-06-30 22:45:56 +0200
committercashmere <cashmere@autistici.org>2026-06-30 22:45:56 +0200
commit03ea2388a79dd428f20542380f22d64500659298 (patch)
tree61f5fceed2306211a0485cef9ba6f8c550548179 /src
parent9b1156e6735c5212b691069f0d9b3a0434fa7e9e (diff)
downloadtelnet-03ea2388a79dd428f20542380f22d64500659298.tar.gz
src/main.c: add struct client
Diffstat (limited to 'src')
-rw-r--r--src/main.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index bbf26e1..4847bab 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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) {