Unable to find the reference to code example on microsoft docs

124 views Asked by At

I'm going through the example code in https://learn.microsoft.com/en-us/dotnet/api/system.net.sockets.socketasynceventargs?redirectedfrom=MSDN&view=netframework-4.8 to understand it and get it working, however when i copied it over to try it out, under the Init() function

readWriteEventArg.UserToken = new AsyncUserToken();

the AsyncUserToken(); type or namespace cannot be found. I've created classes for the SetBuffer(Byte[], Int32, Int32) method and the SocketAsyncEventArgs constructor which the SocketAsyncEventArgs class both uses, but am stuck on finding this AsyncUserToken();

1

There are 1 answers

0
Youssef13 On BEST ANSWER

I've found the missing class in the samples repository.

Here it is:

class AsyncUserToken
{
    Socket m_socket;

    public AsyncUserToken() : this(null) { }

    public AsyncUserToken(Socket socket)
    {
        m_socket = socket;
    }

    public Socket Socket
    {
        get { return m_socket; }
        set { m_socket = value; }
    }

}

I've also opened an issue in the dotnet-api-docs repo.