TsgcWebSocketHTTPServerProperties › Bindings

Bindings 属性

服务器监听的 IP/端口对集合;使用它可同时绑定多个端点。

语法

property Bindings: TIdSocketHandles read GetBindings write SetBindings;

默认值

—(空;服务器回退到所有接口上的 Port

备注

每个 IP/端口组合为服务器添加一个监听条目。每个条目公开 IPPortIPVersion;当集合为空时,服务器在 Port 上绑定所有网络接口。使用 Bindings 可在同一个组件上同时提供 HTTP 和 HTTPS 端点,或将服务器限制在某个物理接口上。如果您计划在重启前重新分配监听端点,请在停止服务器后调用 Bindings.Clear()

示例


oServer := TsgcWebSocketHTTPServer.Create(nil);
With oServer.Bindings.Add do
begin
  IP := '127.0.0.1';
  Port := 80;
end;
With oServer.Bindings.Add do
begin
  IP := '127.0.0.1';
  Port := 443;
end;
oServer.Active := true;

返回属性