Exemplo n.º 1
0
 public AsyncSendBufferManager(int bufferSize)
 {
     m_dynamicBufferManager    = new DynamicBufferManager(bufferSize);
     m_sendBufferList          = new List <SendBufferPacket>();
     m_sendBufferPacket.Offset = 0;
     m_sendBufferPacket.Count  = 0;
 }
Exemplo n.º 2
0
 public AsyncSocketUserToken(int asyncReceiveBufferSize)
 {
     Num                          = 0;
     GateWayId                    = 0;
     m_connectSocket              = null;
     EndPoints                    = null;
     m_asyncSocketInvokeElement   = null;
     m_receiveEventArgs           = new SocketAsyncEventArgs();
     m_receiveEventArgs.UserToken = this;//重点!解释了 AsyncSocketUserToken userToken = asyncEventArgs.UserToken as AsyncSocketUserToken; 其中的asyncEventArgs是userToken.ReceiveEventArgs。
     m_asyncReceiveBuffer         = new byte[asyncReceiveBufferSize];
     m_receiveEventArgs.SetBuffer(m_asyncReceiveBuffer, 0, m_asyncReceiveBuffer.Length);
     m_sendEventArgs           = new SocketAsyncEventArgs();
     m_sendEventArgs.UserToken = this;
     m_receiveBuffer           = new DynamicBufferManager(ProtocolConst.InitBufferSize);
     m_sendBuffer = new AsyncSendBufferManager(ProtocolConst.InitBufferSize);;
 }