//抓取服务器 的TIdHTTPServer初始化和侦听函;

 1 procedure TMainForm.SetServerHostAndPort;
 2 var
 3   Binding : TIdSocketHandle;
 4 begin
 5   idhtpsrvr1.Bindings.Clear;
 6   //1.绑定IP地址和端口
 7   idhtpsrvr1.DefaultPort := 80;   //若有固定绑定端口参数,一定要写这个
 8   Binding := idhtpsrvr1.Bindings.Add;
 9   Binding.IP := sIP;         //本服务的IP
10   Binding.Port := sPort;  //本服务的端口
11 end;
12 
13 //guoqiang.xu 开启http监听
14     try
15       SetServerHostAndPort;
16       idhtpsrvr1.Active := True;
17       if idhtpsrvr1.Active then
18         LogInfo('监听服务器启动成功!', true)
19       else
20         LogInfo('监听服务器启动失败!', true);
21     except on E : Exception do
22       begin
23         LogInfo('监听服务器启动失败!'+ E.Message, true);
24       end;
25     end;
26     //
27     LogInfo('初始化成功', True);
初始化

相关文章:

  • 2021-09-15
  • 2022-02-24
  • 2021-09-09
  • 2022-02-21
  • 2021-08-12
  • 2021-09-22
  • 2022-02-13
  • 2022-01-29
猜你喜欢
  • 2022-12-23
  • 2021-07-18
  • 2021-07-04
  • 2021-09-26
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案