我基于OneConnector示例创建了一个简单的嵌入式jetty项目。
当我开始示例时,我看到一个处于侦听状态的TCP连接,我希望看到它。在已建立的状态下还有相当多的TCP连接。
为什么他们在那里,怎么会有这么多以及它们用于什么?
在TCPView中,我看到以下连接:
java.exe:14536 TCP my-pc:8080 my-pc.tfs.attix5.com:0 LISTENING
java.exe:14536 TCP my-pc:56791 localhost:56792 ESTABLISHED
java.exe:14536 TCP my-pc:56792 localhost:56791 ESTABLISHED
java.exe:14536 TCP my-pc:56793 localhost:56794 ESTABLISHED
java.exe:14536 TCP my-pc:56794 localhost:56793 ESTABLISHED
java.exe:14536 TCP my-pc:56795 localhost:56796 ESTABLISHED
java.exe:14536 TCP my-pc:56796 localhost:56795 ESTABLISHED
java.exe:14536 TCP my-pc:56797 localhost:56798 ESTABLISHED
java.exe:14536 TCP my-pc:56798 localhost:56797 ESTABLISHED
java.exe:14536 TCP my-pc:56799 localhost:56800 ESTABLISHED
java.exe:14536 TCP my-pc:56800 localhost:56799 ESTABLISHED
java.exe:14536 TCP my-pc:56801 localhost:56802 ESTABLISHED
java.exe:14536 TCP my-pc:56802 localhost:56801 ESTABLISHED
java.exe:14536 TCP my-pc:56803 localhost:56804 ESTABLISHED
java.exe:14536 TCP my-pc:56804 localhost:56803 ESTABLISHED
java.exe:14536 TCP my-pc:56805 localhost:56806 ESTABLISHED
java.exe:14536 TCP my-pc:56806 localhost:56805 ESTABLISHED
答案 0 :(得分:0)
从source code开始,默认情况下就是这样......
_manager = new ServerConnectorManager(
getExecutor(),
getScheduler(),
selectors>0?
selectors:
Math.max(1,Math.min(4,Runtime.getRuntime().availableProcessors()/2)
));
addBean(_manager, true);
事实证明,它基于您拥有的处理器数量与默认启动的选择器数量相关。