title: Best way to associate data with SOCKET in windows to use in recv/WSARecv hook
body: <p>I am writing the dll which hooks WSARecv/recv and other networking functions and I need to asocciate some data with user connection (SOCKET), and use it in WSARecv/recv/WSASend/send hook.
  I am wondering, what is the best and fastest (in terms of performance) way to do this?</p>
  
  <p>Way I am doing it right now is really simple: I have an array of SOCKETS (like <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms737873%28v=vs.85%29.aspx" rel="nofollow">fd_set</a>), and second array with the same index (aka fd), where I store structure with my info.</p>
  
  <p>Problem of this method is obvious - each time I have to hook incoming or outcoming packet, I have to loop over my fd_array and find fd (index) by SOCKET, and then use it to access the data in the second array. This makes troubles when my server has over 1000 connections (I have to loop over an array with 1000 elements to find fd each time server sends or receives a packet).</p>
  
  <p>Are there any better and faster ways to do this? </p>