agent.createConnection(options[, callback])
options<Object> 包含连接详细信息的选项。检查net.createConnection()以了解选项的格式callback<Function> 接收已创建套接字的回调函数- 返回:<stream.Duplex>
生成用于 HTTP 请求的套接字/流。
【Produces a socket/stream to be used for HTTP requests.】
默认情况下,该函数与 net.createConnection() 相同。但是,如果需要更大的灵活性,自定义代理可以覆盖此方法。
【By default, this function is the same as net.createConnection(). However,
custom agents may override this method in case greater flexibility is desired.】
可以通过两种方式提供套接字/流:一种是从此函数返回套接字/流,另一种是将套接字/流传递给 callback。
【A socket/stream can be supplied in one of two ways: by returning the
socket/stream from this function, or by passing the socket/stream to callback.】
此方法保证返回一个 <net.Socket> 类的实例,该类是 <stream.Duplex> 的子类,除非用户指定了除 <net.Socket> 之外的套接字类型。
【This method is guaranteed to return an instance of the <net.Socket> class, a subclass of <stream.Duplex>, unless the user specifies a socket type other than <net.Socket>.】
callback 的签名是 (err, stream)。