Exemplo n.º 1
0
 internal void Start(int idleTimeMilliSeconds, EndPoint tcpAddress, EndPoint udpAddress
                     )
 {
     tcpServer = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.NewCachedThreadPool
                                                                           (), Executors.NewCachedThreadPool()));
     tcpServer.SetPipelineFactory(new _ChannelPipelineFactory_100(this, idleTimeMilliSeconds
                                                                  ));
     udpServer = new ConnectionlessBootstrap(new NioDatagramChannelFactory(Executors.NewCachedThreadPool
                                                                               ()));
     udpServer.SetPipeline(Channels.Pipeline(RpcUtil.StageRpcMessageParser, handler, RpcUtil
                                             .StageRpcUdpResponse));
     tcpChannel = tcpServer.Bind(tcpAddress);
     udpChannel = udpServer.Bind(udpAddress);
     allChannels.AddItem(tcpChannel);
     allChannels.AddItem(udpChannel);
     Log.Info("Portmap server started at tcp://" + tcpChannel.GetLocalAddress() + ", udp://"
              + udpChannel.GetLocalAddress());
 }
Exemplo n.º 2
0
        public virtual void Run()
        {
            // Configure the client.
            DatagramChannelFactory f = new NioDatagramChannelFactory(Executors.NewCachedThreadPool
                                                                         (), workerCount);

            server = new ConnectionlessBootstrap(f);
            server.SetPipeline(Channels.Pipeline(RpcUtil.StageRpcMessageParser, rpcProgram, RpcUtil
                                                 .StageRpcUdpResponse));
            server.SetOption("broadcast", "false");
            server.SetOption("sendBufferSize", SendBufferSize);
            server.SetOption("receiveBufferSize", ReceiveBufferSize);
            // Listen to the UDP port
            ch = server.Bind(new IPEndPoint(port));
            IPEndPoint socketAddr = (IPEndPoint)ch.GetLocalAddress();

            boundPort = socketAddr.Port;
            Log.Info("Started listening to UDP requests at port " + boundPort + " for " + rpcProgram
                     + " with workerCount " + workerCount);
        }