zoukankan      html  css  js  c++  java
  • Indy UDP端口冲突解决

    unit Unit1;

    interface

    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, IdBaseComponent, IdComponent, IdUDPBase, IdUDPServer, StdCtrls,idsockethandle;

    type
      TForm1 
    = class(TForm)
        Button1: TButton;
        IdUDPServer1: TIdUDPServer;
        procedure Button1Click(Sender: TObject);
      
    private
        
    { Private declarations }
      
    public
        
    { Public declarations }
      end;

    var
      Form1: TForm1;

    implementation

    {$R *.dfm}

    procedure TForm1.Button1Click(Sender: TObject);
    var ok:boolean ;
    tempport:integer;
    asockethandle:tidsockethandle;
    begin
    tempport:
    =idudpserver1.DefaultPort;
    repeat
    try
    idudpserver1.Active:
    =true;
    ok:
    =true;
    except
      on EIdCouldNotBindSocket 
    do
        begin
          IdUDPServer1.Active:
    =false;
          IdUDPServer1.Bindings.Clear;
          ASocketHandle:
    =IdUDPServer1.Bindings.Add;
          tempport:
    =tempport+1;
          ASocketHandle.Port:
    =tempport ;

        end;
    end;
    until ok;
    showmessage(inttostr(idudpserver1.Binding.Port));
    end;

    end.
  • 相关阅读:
    利用Telnet来模拟Http请求 有GET和POST两种
    WebConfig特殊字符的转义!
    userprofile同步用户失败的原因和解决方案
    linux mysql表名大小写
    web.py 中文模版报错
    docker 开启远程
    web.py 笔记
    python 安装influxdb-python
    安装pip
    influxdb 命令
  • 原文地址:https://www.cnblogs.com/goodloop/p/62825.html
Copyright © 2011-2022 走看看