agent.keepSocketAlive(socket)


socket 从请求中分离并可能由 Agent 持久化时调用。默认行为是:

【Called when socket is detached from a request and could be persisted by the Agent. Default behavior is to:】

socket.setKeepAlive(true, this.keepAliveMsecs);
socket.unref();
return true; 

此方法可以被某个特定的 Agent 子类重写。如果此方法返回一个假值,套接字将被销毁,而不是保留以供下一个请求使用。

【This method can be overridden by a particular Agent subclass. If this method returns a falsy value, the socket will be destroyed instead of persisting it for use with the next request.】

socket 参数可以是 <net.Socket> 的一个实例,或者是 <stream.Duplex> 的一个子类。

【The socket argument can be an instance of <net.Socket>, a subclass of <stream.Duplex>.】