Skip to content

Commit e3d9973

Browse files
committed
Server now prints correct connection IDs
1 parent 920af6b commit e3d9973

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/server.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,11 @@ int server(char *config_file)
199199
}
200200
}
201201

202-
printf("Created new connection with ID %d\n", num_connections);
203-
connections[num_connections].id = connection_id_counter++;
204-
connections[num_connections].addr = client_addr;
202+
connection_index = num_connections;
203+
connections[connection_index].id = connection_id_counter++;
204+
connections[connection_index].addr = client_addr;
205205
num_connections++;
206-
connection_index = num_connections - 1;
206+
printf("Created new connection with ID %d\n", connections[connection_index].id);
207207
}
208208

209209
// Update the last activity time

0 commit comments

Comments
 (0)