Hi there.

I am attempting to write a simple game over a network. Have you ever seen the game 'Anagrammatic' before? Well it's that but simpler. Basically, a client connects to a server and the server pairs the client with another client in order for them to play against each other. Just as if you connected to a game server to play checkers with somebody.

The problem I'm having is I would like to use select() do deal with the clients, but I'm still having a few difficulties understanding the function. I understand it blocks a specified amount of time until data can be read from/written to a file descriptor. But I'm not sure how to implement the 2 player nature of the game. For example, say I do:

Code:
while(1) {
   if(select( fdmax+1,&read_fs,NULL,NULL,NULL)==-1){
       perror("select() failed:");
       exit(1);
   }

   for(i = 0; i <= fdmax; i++) {
      if(FD_ISSET(i, &read_fs)) {
        /* ???? */
      }
   }

}
And i is the listening socket. Say I need to pair that new connection with one already waiting for an opponent, how would I go about that? And how would I keep the client who connected who hasn't got someone to play yet? Do I create an opponent struct and fill it in when two clients are paired or something? I'm guess I'm just generally confused as how to go about the mutliplayer aspect of the project.

Thanks for any advice.