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; } }
public void Start() { lock (this) { tcpListener = new ZTcpListener(IPAddress.Any, port); tcpListener.Start(); tcpListener.BeginAcceptTcpClient(new AsyncCallback(Acceptor), tcpListener); } }