public MulticastPublisherReader(
            string name,
            Group group,
            int incomingSocketPort,
            int maxMessageSize,
            IChannelReaderConsumer consumer,
            ILogger logger)
        {
            _name           = name;
            _maxMessageSize = maxMessageSize;
            _consumer       = consumer;
            _logger         = logger;
            _acceptDone     = new ManualResetEvent(false);
            _groupAddress   = new IPEndPoint(IPAddress.Parse(group.Address), group.Port);
            _messageQueue   = new Queue <RawMessage>();

            _publisherChannel                     = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            _publisherChannel.Blocking            = false;
            _publisherChannel.ExclusiveAddressUse = false;
            // binds to an assigned local address that is
            // published as my availabilityMessage
            _publisherChannel.Bind(new IPEndPoint(IPAddress.Any, 0));

            _readChannel                     = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            _readChannel.Blocking            = false;
            _readChannel.ExclusiveAddressUse = false;
            _readChannel.Bind(new IPEndPoint(IPAddress.Any, incomingSocketPort));
            _readChannel.Listen(120);

            _publisherAddress = (IPEndPoint)_readChannel.LocalEndPoint;

            _clientReadChannels = new List <Socket>();

            _availability = AvailabilityMessage();
        }
    public void OpenFor(IChannelReaderConsumer consumer)
    {
        if (_closed)
        {
            return;
        }

        _consumer = consumer;
    }
Example #3
0
        public void OpenFor(IChannelReaderConsumer consumer)
        {
            // for some tests it's possible to receive close() before start()
            if (_closed)
            {
                return;
            }

            _consumer = consumer;
            Logger.Debug($"{GetType().Name}: OPENING PORT: {_port}");
            _channel.Bind(new IPEndPoint(IPAddress.Any, _port));
            _channel.Listen(120);
        }
    public MulticastPublisherReader(
        string name,
        Group group,
        int incomingSocketPort,
        int maxMessageSize,
        IChannelReaderConsumer consumer,
        ILogger logger)
    {
        _name           = name;
        _maxMessageSize = maxMessageSize;
        _consumer       = consumer;
        _logger         = logger;
        _groupAddress   = new IPEndPoint(IPAddress.Parse(group.Address), group.Port);
        _messageQueue   = new ConcurrentQueue <RawMessage>();

        _publisherChannel                     = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
        _publisherChannel.Blocking            = false;
        _publisherChannel.ExclusiveAddressUse = false;
        // binds to an assigned local address that is
        // published as my availabilityMessage
        _publisherChannel.Bind(new IPEndPoint(IPAddress.Any, 0));

        _readChannel                     = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        _readChannel.Blocking            = false;
        _readChannel.ExclusiveAddressUse = false;
        _readChannel.Bind(new IPEndPoint(IPAddress.Any, incomingSocketPort));
        _readChannel.Listen(120);

        _publisherAddress = (IPEndPoint)_readChannel.LocalEndPoint;

        _clientReadChannels           = new ConcurrentBag <Socket>();
        _socketChannelSelectionReader = new SocketChannelSelectionReader(this, logger);

        _availability = AvailabilityMessage();

        _logger.Debug($"Creating MulticastPublisherReader with read channel on {_readChannel.LocalEndPoint} on port {incomingSocketPort}");
    }
Example #5
0
 public void OpenFor(IChannelReaderConsumer consumer)
 {
     _consumer = consumer;
 }