下载了个netty 4.1.48版本,运行里面自带的一个http server的样例,想看看网络情况,一打开看到那么多的本地IP环回,我看了其它程序最多也就两个左右,为什么netty那么多?这算是TCP连接吗?自已连自己通信??我一连好几个问号。
上图
在命令符下用 netstat -an -p tcp -b
对应的就是这样的。
后来查阅了很多资料都没找到原因,今天无意中,看到一篇文章,心中疑团顿时释然
原文地址:https://blog.csdn.net/haoel/article/details/2224055
大致意思:
Windows下,Selector.open()会自己和自己建立两条TCP链接。不但消耗了两个TCP连接和端口,同时也消耗了文件描述符。
Linux下,Selector.open()会自己和自己建两条管道。同样消耗了两个系统的文件描述符。
看来netty使用了好多的Selecter.open()