public RecivePacket(NetPacketHead packHead) { buffer = new byte[packHead.GetPackLen() + packHead.HeadLen]; headLength = packHead.HeadLen; writePos = 0; Write(packHead.Buffer, 0, packHead.HeadLen); }
public TCPSocketToken(int sendBufferSize, int reciveBufferSize, TCPConnectPool conPool) { connnectPool = conPool; currPackHead = new NetPacketHead(conPool.Packethead); byte[] sendBuffer = new byte[sendBufferSize]; sendSAEA = new SocketAsyncEventArgs(); sendSAEA.SetBuffer(sendBuffer, 0, sendBuffer.Length); sendSAEA.UserToken = this; sendSAEA.Completed += new EventHandler <SocketAsyncEventArgs>(conPool.OnIOCompleted); byte[] reciveBuffer = new byte[reciveBufferSize]; reciveSAEA = new SocketAsyncEventArgs(); reciveSAEA.SetBuffer(reciveBuffer, 0, reciveBuffer.Length); reciveSAEA.UserToken = this; reciveSAEA.Completed += new EventHandler <SocketAsyncEventArgs>(conPool.OnIOCompleted); }