【发布时间】:2012-10-09 00:21:58
【问题描述】:
我正在使用 Embarcadero RAD Studio XE2 Update 4 和随附的 Indy 包。
我的目的是在 LAN 中找到一个服务器,该服务器具有来自 TIdUDPClient 的广播,该客户端等待来自服务器的响应以获取其 IP。如果我使用不带参数的 TIdUDPClient 方法 ReceiveString 接收数据工作正常。
但是,当我尝试使用 RAD Studio 附带的 Indy 10 文档版本 10.5.8.3 中的重载版本时,它无法编译并显示 'E2250:没有重载版本的 'ReceiveString' 可以用这些参数调用'。 这是我的代码:
unit Client;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, IdBaseComponent, IdComponent, IdUDPBase,
IdUDPClient, Vcl.StdCtrls, IdGlobal;
type
TFormLC = class(TForm)
UDPClient: TIdUDPClient;
LServer: TLabel;
Label2: TLabel;
Label3: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
FormLC: TFormLC;
implementation
{$R *.dfm}
function findServer:string;
var ans, ip : string;
port: TIdPort;
begin
with FormLC.UDPClient do begin
Active := True;
BroadcastEnabled:=True;
Broadcast('ServerRequest', 1234);
ans := ReceiveString(ip, port);
Active := False;
end;
if SameText(ans, 'ServerAccept') then
result := ip
else
result := '';
end;
procedure TFormLC.Button1Click(Sender: TObject);
var ans:string;
begin
LServer.Caption := findServer;
end;
end.
我注意到 Indy 的 online documentation 与 IDE 附带的文档不同,并按照那里的描述进行了尝试,但没有成功。
任何帮助都会很棒!
【问题讨论】:
标签: delphi compiler-errors delphi-xe2 broadcast indy10