private void BeginAcceptCallback(IAsyncResult asyncResult) { if (_stop) { return; } try { Socket accepted = _listener.EndAccept(asyncResult); if (_stop) { return; } SocketPongClient newClient = new SocketPongClient(accepted, _useTls, _readBufferSize, _certFile, _pvkFile, _pvkPassword); _connectedClients.Add(newClient); newClient.ExceptionOccurred += new ExceptionOccurredEventHandler(OnExceptionOccurred); newClient.Start(); if (_stop) { return; } _listener.BeginAccept(new AsyncCallback(BeginAcceptCallback), null); } catch (Exception ex) { OnExceptionOccurred(ex); } }
private void BeginAcceptCallback(IAsyncResult asyncResult) { if (_stop) return; try { Socket accepted = _listener.EndAccept(asyncResult); if (_stop) return; SocketPongClient newClient = new SocketPongClient(accepted, _useTls, _readBufferSize, _certFile, _pvkFile, _pvkPassword); _connectedClients.Add(newClient); newClient.ExceptionOccurred += new ExceptionOccurredEventHandler(OnExceptionOccurred); newClient.Start(); if (_stop) return; _listener.BeginAccept(new AsyncCallback(BeginAcceptCallback), null); } catch (Exception ex) { OnExceptionOccurred(ex); } }