Registriert seit: 30. Nov 2005
Ort: München
5.768 Beiträge
Delphi 10.4 Sydney
|
Re: Indy 9 Sample - UDPClientServer - Delphi 6 -> 2006 ?!
16. Dez 2008, 20:26
Delphi-Quellcode:
//procedure TUDPMainForm.UDPServerUDPRead(Sender: TObject; AData: TStream; ABinding: TIdSocketHandle);
procedure TUDPMainForm.UDPServerUDPRead(Sender: TObject; AData: TBytes; ABinding: TIdSocketHandle);
var
DataStringStream: TStringStream;
s: String;
begin
DataStringStream := TStringStream.Create('');
try
// s := BytesToString(AData);
DataStringStream.CopyFrom(AData,length(AData)); // <- length eingesetzt
UDPMemo.Lines.Add('Received "' + DataStringStream.DataString + '" from ' + ABinding.PeerIP + ' on port ' + IntToStr(ABinding.PeerPort));
s := 'Replied from ' + UDPServer.Name + ' to "' + DataStringStream.DataString + '"';
ABinding.SendTo(ABinding.PeerIP, ABinding.PeerPort, (s[1]), Length(s));
finally
DataStringStream.Free;
end;
end;
TBytes = Array of Byte
Vielleicht geht es wie oben beschrieben.
Grüße
Klaus
Klaus
|