Beispiel #1
0
        public void Stop(string ip, int port)
        {
            string _IpPorts = string.Format("{0}:{1}", ip, port);

            if (dict_Channel_Listen.ContainsKey(_IpPorts))
            {
                Beetle.IChannel _channel = dict_Channel_Listen[_IpPorts];
                if (_channel.Socket != null)
                {
                    _channel.Socket.Shutdown(System.Net.Sockets.SocketShutdown.Both);
                }
                //    _channel.Socket.Disconnect(true);
                // _srv.Server.Socket.Disconnect(true);
                if (_channel.Server != null)
                {
                    _channel.Server.Dispose(); //
                }
                _channel.Dispose();            //
                dict_Channel_Listen.Remove(_IpPorts);
            }
            else if (!string.IsNullOrEmpty(_IpPorts))
            {
                //_srv.Server.Socket.Disconnect(true);
                if (_srv.Server != null)
                {
                    _srv.Server.Dispose();
                }
                _srv.Dispose();
            }
            else
            {
                MessageBox.Show("Stop(" + _IpPorts + ")");
            }
        }
Beispiel #2
0
        public void do_Disconnect()
        {
            if (m_channel == null)
            {
                return;
            }
            if (m_channel.Socket == null)
            {
                return;
            }

            if (!(m_channel.Socket.Connected && !m_channel.IsDisposed))
            {
                return;
            }
            m_channel.Dispose();
        }