在 Windows 上为一个 libevent 绑定创建了 3 个套接字?

3 sockets created for one libevent bind on Windows?

我正在编写一个 BitTorrent 客户端来学习更多关于网络的知识,我有一些我正在努力 Google 的东西。作为 BT 规范的一部分,我需要一台服务器来侦听与我的计算机的对等连接。在 win32 端口中,我有这样的代码来设置我的服务器

struct sockaddr_in saServer;
struct hostent* localHost;
char* localIP;

// Get the local host information
localHost = gethostbyname("");
localIP = inet_ntoa(*(struct in_addr *)*localHost->h_addr_list);

saServer.sin_family = AF_INET;
saServer.sin_addr.s_addr = inet_addr(localIP);
saServer.sin_port = htons(6881);


struct evconnlistener *listener = evconnlistener_new_bind(base, accept_conn_cb, NULL,
    LEV_OPT_CLOSE_ON_FREE | LEV_OPT_REUSEABLE, -1, (SOCKADDR*)&saServer, sizeof(saServer));

这似乎可行,但如果我查看 netstat,我会看到以下内容,

BitTorrentClient.exe    6092    TCP hostname    50216   localhost   50217   ESTABLISHED                                     
BitTorrentClient.exe    6092    TCP hostname    50217   localhost   50216   ESTABLISHED                                     
BitTorrentClient.exe    6092    TCP hostname.home 6881  hostname    0   LISTENING   

为什么还有另外两个连接,一个来自端口 50216->50217,一个从 50217->50216 环回?我应该在端口 6881 上只有一个监听连接。这是一个 libevent 怪癖,还是与网络相关的更基本的东西?

我可以搜索什么来了解其他两个端口的用途?

这很可能是 libevent 在内部调用 evutil_make_internal_pipe_ 的结果。

Libevent 为 inter-thread communication and signal delivery using socketpair(2) on POSIX-compliant systems, whereas on Windows libevent has to resort to manually connecting two sockets together 创建内部 "pipes"。