与服务器build立多个连接有什么意义?

Server对象是主应用程序容器。 服务器pipe理所有传入连接以及框架提供的所有function。 服务器可以包含多个连接(例如,监听端口80和8080)。

与服务器build立多个连接有什么意义? 记忆? 速度? 安全?

最明显的用例是允许将TLS和非TLS请求路由到同一台服务器。 你build立2个连接到同一个服务器,一个使用TLSconfiguration,另一个没有。

var Hapi = require('hapi'); var server = new Hapi.Server(); // Receives TLS requests server.connection({ port: 443, tls: { key: ..., cert: ... } }); // Requests HTTP requests server.connection({ port: 80 }); ...