Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Server startup of netty source code analysis

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

ServerBootstrap and Bootstrap are the boot classes of server and client in netty respectively, which are mainly responsible for initialization, configuration and boot of server and client. Then we will make a simple analysis of the source code of ServerBootstrap and Bootstrap through the examples in netty source code. First of all, we know that both classes inherit from the AbstractBootstrap class

Then we will start with an example of ServerBootstrap in the netty source code to make a simple analysis of it.

/ / Configure the server.

EventLoopGroup bossGroup = new NioEventLoopGroup (1)

EventLoopGroup workerGroup = new NioEventLoopGroup ()

Final EchoServerHandler serverHandler = new EchoServerHandler ()

Try {

/ / initialize a server boot class

ServerBootstrap b = new ServerBootstrap ()

B.group (bossGroup, workerGroup) / / set thread group

The IO model of .channel (NioServerSocketChannel.class) / / sets ServerSocketChannel is divided into epoll and Nio

.option (ChannelOption.SO_BACKLOG, 100) / / set the option parameter and save it as a LinkedHashMap

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report