Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AsyncUserToken class is missing in SocketAsyncEventArgs sample: How to make the sample works?

Tags:

c#

.net

tcp

sockets

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.

like image 412
AkariKamigishi Avatar asked Apr 01 '13 05:04

AkariKamigishi


1 Answers

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; }
}
like image 102
Yves M. Avatar answered Nov 04 '22 10:11

Yves M.