问题
I am working on TCP multithread server and 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:
The type or namespace name 'AsyncUserToken' could not be found (are you missing a using directive or an assembly reference?)
I cant find what namespace to include even I searched it on Google, here are those I currently 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 help.
回答1:
The AsyncUserToken
class is not part of the .NET framework. It looks like it has been forgotten in the Microsoft sample.
You can create yourself the AsyncUserToken
class with a Socket
property (corresponding to the socket used to perform the I/O operations) :
internal class AsyncUserToken
{
public System.Net.Sockets.Socket Socket { get; set; }
}
回答2:
Well, I guess I found something related: http://www.codeproject.com/Articles/22918/How-To-Use-the-SocketAsyncEventArgs-Class
来源:https://stackoverflow.com/questions/15738062/asyncusertoken-class-is-missing-in-socketasynceventargs-sample-how-to-make-the