edit: oops, solved it on my own
turns out SOCKET is an int anyway.
-------------------------------
Hi, I have encountered the first time I need to use the STL map container and it's confusing me.
Firstly I will describe the situation:
I am programming a simple winsock2 server.
My client objects contain the socket objects. (apart from the listener)
My client objects are stored in a STL list contained in the core server object.
I am looping through the fd_set outputted by select() and I must find a way to reference the client objects from the socket objects in the fd_set member array fd_array. I believe I need to use a hash table to do so, hence why I need to understand maps. I wouldn't be having problems if it was a simple map of normal data types, but things seem to get confusing if you want anything more than just ints/floats/longs etc. I believe the map must be defined as follows:
std::map<SOCKET,std::list<ribClient*>::iterator> sockMap;
(except with a 3rd argument for the comparison function that I have to make)
That will allow me to find the list iterator for the client which contains the SOCKET, I think.
What confuses me is how I make the comparison function; I have been reading about maps and it seems my comparison function must output whether one SOCKET is lower than the other... how is it possible for a SOCKET to have a higher or lower value than any other SOCKET? Am I doing this totally wrong or have I encountered a genuine problem to overcome?
Also, how does the insert argument for position work? I understand that it is a map iterator, but where is the best place to have it pointing to?
Thanks for the help.