jetty学习1-SelectChannelConnector

本文详细探讨了Jetty Server中的SelectChannelConnector组件,分析了其内部的accept线程和Acceptor线程的角色。重点介绍了如何处理socket连接,包括注册read事件、创建HttpConnection,并关注了MaxIdleTime参数的作用,即超时后关闭连接的机制。同时提到了检查超时事件的时间点,如endpoint创建、http头解析和handler处理。
摘要由CSDN通过智能技术生成

1.jetty Server的主要结构如下:

The Jetty Server is the plumbing between a collection of Connectors that accept HTTP connections, and a collection of Handlers that service requests from the connections and produce responses, with the work being done by threads taken from a thread pool. 

server主要就是吧connector,handler和ThreadPool结合起来.,这里主要针对SelectChannelConnector分析:

 

其中connector又有两个角色:

  • 一个是负责socket.accept()的线程,所做的工作就是accept,然后把socketChannel放入队列,等待别的模块处理,类似与tomcat或者其他容器的bio的方式:
        _manager.dispatch(new Runnable()
        {
            public void run()
            {
                final ServerSocketChannel server=_acceptChannel;
                while (isRunning() && _acceptChannel==server && server.isOpen())
                {
                    try
                    {
                        SocketChannel channel = server.accept();
                        channel.configureBlocking(false);
                        Socket socket = channel.socket();
                        configure(socket);
              
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值