Starting acceptors in "paused" state

32 views
Skip to first unread message

Tim Fox

unread,
Dec 1, 2020, 11:30:16 AM12/1/20
to Netty discussions
Hey Norman,

Second question of the day!

I'm porting an existing server to Netty. I have a requirement where I need to have server sockets bound but not in a state where they will accept connections, i.e. without the OP_ACCEPT registered. AUI, clients that attempt to connect during that time will not fail but will be queued until the server is ready to accept connections.

Then some time later I want to say "hey now you can start accepting connections", and then register the OP_ACCEPT. Looking at NioServerSocket it seems currently to always start with OP_ACCEPT.

Any thoughts on how I can achieve this behaviour with Netty?



Norman Maurer

unread,
Dec 1, 2020, 11:37:47 AM12/1/20
to ne...@googlegroups.com
Yep … Thats easy to do.


Just use:

ServerBootstrap bs = new ServerBootstrap();
sb.option(ChannelOption.AUTO_READ, false) ….

And once you want to start accepting use

Channel.config().setAutoRead(true); or channel.config().setOption(ChannelOption.AUTO_READ, true);.


--
You received this message because you are subscribed to the Google Groups "Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netty+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netty/dea89732-c6af-44bf-b26d-f21a1e1939c4n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages