SetDefaultValue() public method

public SetDefaultValue ( ) : void
return void
示例#1
0
 private void Receive_Completed(Socket socket, ServerAsyncEventArgs e)
 {
     try
     {
         Server <C> .Connection <C> connection;
         this.connections.TryGetValue(e.RemoteEndPoint, out connection);
         if (connection != null && connection.Socket == socket && connection.Id == e.ConnectionId)
         {
             while (true)
             {
                 if (e != null)
                 {
                     connection.ReceiveQueue.Put(e);
                     e = null;
                 }
                 e = connection.ReceiveQueue.GetCurrent();
                 if (e == null)
                 {
                     goto IL_D4;
                 }
                 bool flag = true;
                 if (this.isRunning && e.BytesTransferred > 0 && e.SocketError == SocketError.Success)
                 {
                     flag = !this.OnTcpReceived(connection, ref e);
                 }
                 if (flag)
                 {
                     break;
                 }
                 connection.ReceiveQueue.Next();
                 if (e == null)
                 {
                     e = EventArgsManager.Get();
                 }
                 else
                 {
                     e.SetDefaultValue();
                 }
                 if (this.TcpReceiveAsync(connection, e))
                 {
                     e = null;
                 }
             }
             this.connections.Remove(connection.RemoteEndPoint, connection);
             this.EndTcpConnection(connection);
         }
         IL_D4 :;
     }
     finally
     {
         if (e != null)
         {
             EventArgsManager.Put(ref e);
         }
     }
 }
示例#2
0
        private void Receive_Completed(Socket socket, ServerAsyncEventArgs e)
        {
            try
            {
                Connection <C> connection;
                connections.TryGetValue(e.RemoteEndPoint, out connection);

                if (connection != null && connection.Socket == socket && connection.Id == e.ConnectionId)
                {
                    for (; ;)
                    {
                        if (e != null)
                        {
                            connection.ReceiveQueue.Put(e);
                            e = null;
                        }

                        e = connection.ReceiveQueue.GetCurrent();
                        if (e == null)
                        {
                            break;
                        }

                        bool close = true;
                        if (isRunning && e.BytesTransferred > 0 && e.SocketError == SocketError.Success)
                        {
                            close = !OnTcpReceived(connection, ref e);
                        }

                        if (close)
                        {
                            connections.Remove(connection.RemoteEndPoint, connection);
                            EndTcpConnection(connection);

                            break;
                        }
                        else
                        {
                            connection.ReceiveQueue.Next();
                        }

                        if (e == null)
                        {
                            e = EventArgsManager.Get();
                        }
                        else
                        {
                            e.SetDefaultValue();
                        }

                        if (TcpReceiveAsync(connection, e))
                        {
                            e = null;
                        }
                    }
                }
#if DEBUG
                else
                {
                    if (e.BytesTransferred > 0)
                    {
                        Console.WriteLine("ERROR: {0}, conn-handle: {1}, socket-handle: {2}, ip: {3}", e.BytesTransferred,
                                          (connection == null) ? "Null" : connection.Socket.Handle.ToString(), socket.Handle.ToString(),
                                          e.RemoteEndPoint.ToString());
                    }
                }
#endif
            }
            finally
            {
                if (e != null)
                {
                    EventArgsManager.Put(ref e);
                }
            }
        }