How do I unbind a server socket once I call bind()

brea dobleb at gmail.com
Wed May 20 06:12:23 EDT 2009


Hi all,

  A question that I have shutting down a server and ussing what Trustin
explained here...

  I have created a server class with attributes: port, channelFactory,
serverBootstrap and channelGroup. And use a method init() where initialize
this attributes and bind the server.

  The first channel from bootstrap.bind() could be added to channelGroup but
not the other channels because they are created in the handler and in this
handler class there is no visibility of channelGroup attribute.

  There is a sketch of the class structure:

Server.java{

  channelGroup;

  init(){
    new ServerPipelineFactory.java{
         new  ServerHandler.java{}
     }
  }


}


If someone have solved this pattern issue, of have any idea that can help
i'll be very gracefull.

Best Regards,

Brea




dbevenius wrote:
> 
> Hi Virat,
> 
> bootstrap.bind returns a channel which you can then call close() on:
> Channel sc = bootstrap.bind(new InetSocketAddress(PORT));
> sc.close().awaitUninterruptibly();
> 
> Atleast this is what I've been doing and this works for me.
> 
> Regards,
> 
> /Daniel
> 
> 2009/3/9 Virat Gohil (via Nabble)
> <ml-user+190262-330470430 at n2.nabble.com<ml-user%2B190262-330470430 at n2.nabble.com>
>>
> 
>> Hi All,
>>
>> I have created a ServerSocketChannelFactory as follows:
>>
>> factory = new
>> NioServerSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool(),numHandlerThreads);
>> bootstrap = new ServerBootstrap(factory);
>> bootstrap.bind(new InetSocketAddress(PORT));
>>
>> My question is, how do I unbind the port when shutting down my server.
>>
>> Thanks in advance!
>>
>> Virat
>>
>> _______________________________________________
>> netty-users mailing list
>> netty-users at ...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2448201&i=0>
>> https://lists.jboss.org/mailman/listinfo/netty-users
>>
>>
>> ------------------------------
>>  View message @
>> http://n2.nabble.com/How-do-I-unbind-a-server-socket-once-I-call-bind%28%29-tp2448201p2448201.html
>> To start a new topic under Netty User Group, email
>> ml-node+685700-269084044 at n2.nabble.com<ml-node%2B685700-269084044 at n2.nabble.com>
>> To unsubscribe from Netty User Group, click here< (link removed) ==>.
>>
>>
>>
> 
> 

-- 
View this message in context: http://n2.nabble.com/How-do-I-unbind-a-server-socket-once-I-call-bind%28%29-tp2448201p2945333.html
Sent from the Netty User Group mailing list archive at Nabble.com.




More information about the netty-users mailing list