public ClientSocket(ScorpioConnectionFactory factory, bool lengthIncludesLengthFieldLength) { m_State = ClientState.None; m_LengthIncludesLengthFieldLength = lengthIncludesLengthFieldLength; m_Connection = factory.create(); m_ConnectEvent = new SocketAsyncEventArgs(); m_ConnectEvent.Completed += ConnectionAsyncCompleted; }
void AcceptAsyncCompleted(object sender, SocketAsyncEventArgs e) { if (e.SocketError != SocketError.Success) { m_Socket.AcceptAsync(m_AcceptEvent); return; } var connection = m_Factory.create(); connection.SetSocket(this, new ScorpioSocket(m_AcceptEvent.AcceptSocket, m_LengthIncludesLengthFieldLength)); m_Connects.Add(connection); m_AcceptEvent.AcceptSocket = null; BeginAccept(); }