示例#1
0
        public void Stop()
        {
            lock (this)
            {
                if (tcpListener != null)
                {
                    tcpListener.Stop();
                }
                ZRemoteClient[] clients;
                lock (dicClients)
                {
                    clients = dicClients.Values.ToArray();
                    foreach (ZRemoteClient client in clients)
                    {
                        dicClients.Remove(client.IDKey);
                        client.Close();
                    }
                }
                if (OnDisConnect != null)
                {
                    foreach (ZRemoteClient client in clients)
                    {
                        OnDisConnect(this, new ZTcpServerEventArgs(this, client, client.NetWork));
                    }
                }

                tcpListener = null;
            }
        }
示例#2
0
 public void Start()
 {
     lock (this)
     {
         tcpListener = new ZTcpListener(IPAddress.Any, port);
         tcpListener.Start();
         tcpListener.BeginAcceptTcpClient(new AsyncCallback(Acceptor), tcpListener);
     }
 }