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);
            }
        }
Example #2
0
		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);
			}
		}