I have read through the documentation for Winsock2 on MSDN, but I still need clarification on a few things, if anyone can help.
I planned to make something like the the setup you get when you use WSAAsyncSelect(), but using a separate thread. Can I use WSAEventSelect() to link more than one socket to a single event object?
If I used a completion port instead, which events do I get through the completion port? The MSDN has a list in terms of file operations, but I had trouble relating them to which events (FD_READ, FD_WRITE, ect..) would be sent through the completion port. Is there a way to tell which event is completing? or do I have to take note of this and store it in a struct each time I send or recv something?
thanks for any *help anyone can give me on this =D
edit: better yet, would I better off just switching to C# to do this? It seems to be very popular and better suited to this specific task.
No, you cannot link multiple sockets to a single WSAEVENT. You have to call WSACreateEvent() and WSAEventSelect() for each individual socket that you want to receive notifications for. You can use WSAWaitForMultipleEvents() to have a single thread wait for events from multiple sockets, though.
As for using completion ports, I suggest you read MSDN’s articles on the matter, such as:
Windows Sockets 2.0: Write Scalable Winsock Apps Using Completion Ports.