Frage

I am beginner in both Java Socket Programming and Netty. Currently , we have a application which uses a pure Java Socket Connection where we manage the health of socket by our own.

I wish to understand how netty manages sockets? For how long the port will be open? What will happen if socket connection is dropped? How Netty is maintaining the tcp session?

War es hilfreich?

Lösung

Netty is completely transparent with respect to managing the underlying tcp socket details.

For how long the port will be open?

Netty allows you to set SO_TIMEOUT on the channel - this is basically a tcp property that raises read timeout alerts and you can write code to respond to this and drop the connection if you desire so.

See ChannelOptions

What will happen if socket connection is dropped?

If you use a SimpleChannelUpstreamHandler , then its channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) will be invoked.

See SimpleChannelUpstreamHandler

How Netty is maintaining the tcp session?

Not sure exactly what you mean but it basically is the same mechanics used in the a tcp protocol.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top