How to change this code such that instead of using sockname with is an array, it uses a linked list structure and loops through the list?
int accept_connection(int fd, struct sockname *users)
{
    int user_index = 0;
    while (users[user_index].sock_fd != -1)
    {
        user_index++;
    }

    int client_fd = accept(fd, NULL, NULL);
    if (client_fd < 0)
    {
        perror("server: accept");
        close(fd);
        exit(1);
    }

    users[user_index].sock_fd = client_fd;
    users[user_index].username = NULL;
    return client_fd;
}