'connection' 事件

当新的 TCP 流被建立时触发。 socket 是一个 net.Socket 类型的对象。 通常用户无需访问该事件。 因为协议解析器绑定到 socket 的方式,socket 不会触发 'readable' 事件。 socket 也可以通过 request.connection 访问。

该事件也可以通过注入连接到 HTTP 服务器显式地调用。 在这种情况下,可以传入 Duplex 流。

This event is emitted when a new TCP stream is established. socket is typically an object of type net.Socket. Usually users will not want to access this event. In particular, the socket will not emit 'readable' events because of how the protocol parser attaches to the socket. The socket can also be accessed at request.connection.

This event can also be explicitly emitted by users to inject connections into the HTTP server. In that case, any Duplex stream can be passed.