I'm debating on how to map a User struct to their socket file descriptor. I was considering keeping an array of void pointers of a MAX_CONNECTIONS size, and storing the pointer as the value for the key of the file descriptor.
The issue I run into is how I plan on handling my receives. I currently call pipe()
to make a pipe, and then fork()
the process to handle recv
. I would likely want to keep track of these, too, to be able to handle.
What I currently do is loop through a linked list of users, find the one matching the descriptor, and go from there
Question: Is this an efficient and/or acceptable method of mapping sockets to the users connected to them, or should I practice some other sort of voodoo?
I appreciate any effort given toward my (likely pointless) dilemma.