public void SendCommand(string cmd)
        {
            if (this.Server == null || !this.Server.Connected)
            {
                return;
            }
            this.Receive((object)this, new SfinksClient.ReceiveDataEventArgs(cmd));
            byte[]        bytes  = Encoding.UTF8.GetBytes(cmd + "\r\n");
            NetworkStream stream = this.Server.GetStream();

            stream.Write(bytes, 0, bytes.Length);
            stream.Flush();
            this.State                        = new SfinksClient.StateObject();
            this.State.Buffer                 = new byte[100];
            this.State.WorkSocket             = this.Server.Client;
            this.Server.Client.ReceiveTimeout = 500;
            this.Server.Client.BeginReceive(this.State.Buffer, 0, this.State.Buffer.Length, SocketFlags.None, new AsyncCallback(this.OnReceive), (object)this.State);
            this.IsConnected = true;
            this.Receive((object)this, new SfinksClient.ReceiveDataEventArgs("Message Sent"));
        }
        public void OnReceive(IAsyncResult ar)
        {
            SfinksClient.StateObject stateObject = (SfinksClient.StateObject)ar.AsyncState;
            Socket socket = stateObject.WorkSocket;

            if (socket.Connected)
            {
                try
                {
                    int num = socket.EndReceive(ar);
                    this.Receive((object)this, new SfinksClient.ReceiveDataEventArgs("Message Received"));
                    if (num > 0)
                    {
                        this.Receive((object)this, new SfinksClient.ReceiveDataEventArgs(Encoding.UTF8.GetString(stateObject.Buffer)));
                    }
                    else
                    {
                        this.Receive((object)this, new SfinksClient.ReceiveDataEventArgs("Empty request"));
                    }
                }
                catch (SocketException ex)
                {
                    this.Receive((object)this, new SfinksClient.ReceiveDataEventArgs("Error:" + ex.Message));
                    if (ex.ErrorCode != 10054 && (ex.ErrorCode == 10004 || ex.ErrorCode == 10053))
                    {
                        return;
                    }
                    socket.Close();
                }
                catch (Exception ex)
                {
                    this.Receive((object)this, new SfinksClient.ReceiveDataEventArgs("Error:" + ex.Message));
                }
            }
            else
            {
                this.Receive((object)this, new SfinksClient.ReceiveDataEventArgs("Server not connected"));
            }
        }