Esempio n. 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private int listen(int minPort, int maxPort) throws org.jboss.netty.channel.ChannelException
        private int Listen(int minPort, int maxPort)
        {
            ChannelException ex = null;

            for (int checkPort = minPort; checkPort <= maxPort; checkPort++)
            {
                try
                {
                    string            address = _config.clusterServer().Host;
                    InetSocketAddress localAddress;
                    if (string.ReferenceEquals(address, null) || address.Equals(INADDR_ANY))
                    {
                        localAddress = new InetSocketAddress(checkPort);
                    }
                    else
                    {
                        localAddress    = new InetSocketAddress(address, checkPort);
                        BindingDetected = true;
                    }

                    Channel listenChannel = _serverBootstrap.bind(localAddress);

                    ListeningAt(GetURI(localAddress));

                    _channels.add(listenChannel);
                    return(checkPort);
                }
                catch (ChannelException e)
                {
                    ex = e;
                }
            }

            _nioChannelFactory.releaseExternalResources();
            throw ex;
        }