unit TestUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, u_udpSocket;
type
TForm1 =
class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
FSock:TUDP_Socket;
procedure RecvSock(Sender:TObject);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
buffer:
String;
begin
buffer:=#$FE#$FD#$00#$10#$20#$30#$40#$FF#$FF#$FF#$01;
Fsock.Send(buffer[1],length(buffer));
end;
procedure TForm1.RecvSock(Sender: TObject);
var buffer:
array[0..8191]
of byte;
len:Integer;
i,j:integer;
s:
string;
begin
fillchar(buffer,8192,0);
len:=FSock.recv(buffer[0],8192);
memo1.Lines.BeginUpdate;
try
memo1.lines.add(inttostr(len));
for j:=0
to len
div 20
do
begin
s:='
';
for i:=0
to 19
do s:=s+'
'+inttohex(buffer[j*20+i],2);
memo1.lines.add(s);
end;
finally
memo1.lines.EndUpdate;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Fsock:=TUDP_Socket.Create(self);
FSock.onReceiving:=RecvSock;
Fsock.RemoteHost := '
69.12.76.145';
Fsock.RemotePort := 29900;
Fsock.SocketMode := smEvent;
Fsock.Open;
end;
end.