Embarcadero RAD Studio XE2 업데이트 4와 함께 제공된 Indy 패키지를 사용하고 있습니다.Delphi XE2 TIdUDPClient ReceiveString 오버로드가 작동하지 않습니다.
제 의도는 IP를 얻기 위해 서버로부터의 응답을 기다리는 TIdUDPClient로부터의 브로드 캐스트로 LAN에있는 서버를 찾는 것입니다. 인수없이 TIdUDPClient 메서드 ReceiveString 메서드를 사용하면 데이터를받을 수 있습니다.
RAD Studio와 함께 제공되는 10.5.8.3 버전의 Indy 10 Documentation 버전에서 오버로드 된 버전을 사용하려고하면 컴파일되지 않고 'E2250가 표시됩니다.'ReceiveString '의 오버로드 된 버전은 없습니다. 이 인수들로 불리는 '. succes에하지 않고, 거기에 설명 된대로 내가 인디의 online documentation는 IDE와 함께 제공되는 문서와 다른 것을 발견하고 그것을 시도
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.
: 다음은 내 코드입니다.
도움이 될 것입니다.
명확하게'with' 문을 없애십시오 –
+1 : 더 이상'with' –
고마워요! 그게 많은 도움이됩니다! –