The AsyncUserToken class is missing in the SocketAsyncEventArgs example: How do I get the sample to work?

I am working on a multithreaded server and a TCP client. I found some codes from Microsoft websites: http://msdn.microsoft.com/en-us/library/system.net.sockets.socketasynceventargs.aspx

However, I got the following error:

Could not find type or namespace name "AsyncUserToken" (do you have a using directive or an assembly reference?)

I can’t find which namespace to include, even if I searched it on Google, here are the ones I have:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Net.Sockets; using System.Threading; 

Thanks for the help.

+4
source share
2 answers

The AsyncUserToken class AsyncUserToken not part of the .NET platform . It looks like he was forgotten in the Microsoft pattern .

You can create an AsyncUserToken class with the Socket property (corresponding to the socket used to perform I / O):

 internal class AsyncUserToken { public System.Net.Sockets.Socket Socket { get; set; } } 
+3
source

All Articles