protected internal override void ConnectionLost(CloseReason reason)
        {
            if (_dataConnectorHandle != null)
            {
                _dataConnectorHandle.Close();

                _dataConnectorHandle = null;
            }

            base.ConnectionLost(reason);
        }
        internal void HandleDataConnectionMade(RemoteCaptureDataProtocol dataProtocol)
        {
            _dataProtocols.UnionUpdate(dataProtocol);

            if (_dataConnectorHandle != null)
            {
                _dataConnectorHandle.Close();

                _dataConnectorHandle = null;
            }

            _service.AddListener(dataProtocol);
        }
        void HandleStartCaptureRequest(byte[] data)
        {
            // Read in the various fields:
            NetworkReader reader = new NetworkReader(data);

            uint snapLength = reader.ReadUnsigned32();
            uint readTimeout = reader.ReadUnsigned32();
            ushort flags = reader.ReadUnsigned16();
            ushort clientDataPortOrZero = reader.ReadUnsigned16();

            ushort filterType = reader.ReadUnsigned16();
            ushort dummy = reader.ReadUnsigned16();
            uint numberOfItems = reader.ReadUnsigned32();

            for (int i = 0; i < numberOfItems; i++)
            {
                ushort code = reader.ReadUnsigned16();
                byte jumpTrue = reader.ReadUnsigned8();
                byte jumpFalse = reader.ReadUnsigned8();
                int instructionValue = reader.ReadSigned32();
            }

            // Set up a data port:
            if (_dataConnectorHandle == null)
            {
                _dataConnectorHandle = _service.Reactor.ListenStream(new RemoteCaptureProtocolDataFactory(this));
            }

            int bufferSize = (int)snapLength;
            ushort serverDataPort = (ushort)_dataConnectorHandle.ListeningOnPort;

            MemoryStream stream = PrepareSendFrame(RPCAP_VERSION, RPCAP_MSG_STARTCAP_REPLY, 0);
            NetworkWriter writer = new NetworkWriter(stream);

            writer.WriteSigned32(bufferSize);
            writer.WriteUnsigned16(serverDataPort);
            writer.WriteUnsigned16(0); // (This is a reserved field.)

            CompleteSendFrame(stream);
        }
        public void Open(IServiceHost host)
        {
            _reactor = host.Reactor;

            _controlConnector = host.Reactor.ListenStream(new RemoteCaptureProtocolFactory(this), _listenPort);
        }