   Socket multiplexing
  HejI’m coding a transport protocol using udp and I have one last problem to solve.At both nodes there is only one socket no matter how many nodes you are communicating with. But in the end, packets will be routed to the right buffer.I use WsARecvFrom and WSASendTo, winsock2, c++.The problem lies in mapping a specific IP and port to a buffer or pointer o whatever. WSARecvFrom will fill a sockaddr_in struct with IP and port for the node who sent the packet, what I want to do is using that IP and port map a datastucture (representing example a connectionstructure).There are several solutions for the problem but which is the best.#1 Have a array sorted and using bin search.#2 Some kind of hashmap#3 Under the connection handshake sending a array idx to remote node and let him send that idx in every packet. What if someone changed the idx and recalc the crc32, well someone could also change the destport, that also will lead the packet to the wrong buffer.Looking up the datastructure will happen almost at every packet recved. 
  Sounds okay.Another solution is a map.Kuphryn 