public virtual void Send(Packet p)
        {
            if (_socket == null)
            {
                p.OnSend();
                return;
            }

            int length;

            byte[] buffer = p.Compile(_compressionEnabled, out length);

            if (buffer != null)
            {
                if (buffer.Length <= 0 || length <= 0)
                {
                    p.OnSend();
                    return;
                }

                try
                {
                    SocketAsyncEventArgs args = new SocketAsyncEventArgs();

                    args.SetBuffer(buffer, 0, length);
                    args.RemoteEndPoint = _hostEndPoint;
                    args.UserToken      = this;

                    _socket.SendAsync(args);
                }
                catch (CapacityExceededException)
                {
                    Tracer.Error("Too much data pending, disconnecting...");
                    Dispose();
                }
                catch (Exception ex)
                {
                    Tracer.Error(ex);
                    Dispose();
                }

                p.OnSend();
            }
            else
            {
                Tracer.Error("Null buffer send, disconnecting...");
                Tracer.Error(new StackTrace());

                Dispose();
            }
        }
        public virtual void Send(Packet p)
        {
            if (_socket == null)
            {
                p.OnSend();
                return;
            }

            int length;
            byte[] buffer = p.Compile(_compressionEnabled, out length);

            if (buffer != null)
            {
                if (buffer.Length <= 0 || length <= 0)
                {
                    p.OnSend();
                    return;
                }

                try
                {
                    SocketAsyncEventArgs args = new SocketAsyncEventArgs();

                    args.SetBuffer(buffer, 0, length);
                    args.RemoteEndPoint = _hostEndPoint;
                    args.UserToken = this;

                    _socket.SendAsync(args);
                }
                catch (CapacityExceededException)
                {
                    Tracer.Error("Too much data pending, disconnecting...");
                    Dispose();
                }
                catch (Exception ex)
                {
                    Tracer.Error(ex);
                    Dispose();
                }

                p.OnSend();
            }
            else
            {
                Tracer.Error("Null buffer send, disconnecting...");
                Tracer.Error(new StackTrace());

                Dispose();
            }
        }