title: Is there any way to associate a file descriptor with user defined data?
body: <p>I am writing a client-server application, and it uses POSIX <code>poll</code> function to provide a form of concurrent client handling. Clients also have state and other related data, which is stored in a client structure. </p>
  
  <p>My immediate problem is that when I get a hint from <code>poll</code> to do I/O on a socket file descriptor that is associated with a client (conceptually), I have to actually match the file descriptor to its associated client data structure. Currently I do a <code>O(n_clients)</code> lookup (my client data structure stores the descriptor), but I was wondering whether there exists a better alternative?</p>