unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, NMUDP;
type
TForm1 = class(TForm)
NMUDP1: TNMUDP;
Edit1: TEdit;
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure NMUDP1DataReceived(Sender: TComponent; NumberBytes: Integer;
FromIP: String; Port: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Txt
char;
begin
if Edit1.Text = '' then
exit;
GetMem(Txt,Length(Edit1.Text)+1);
ZeroMemory(Txt,Length(Edit1.Text)+1);
Txt:=Pchar(Edit1.Text);
NMUDP1.RemoteHost := '61.189.132.95';
NMUDP1.RemotePort := 6767;
NMUDP1.SendBuffer(Txt^,Length(Edit1.Text)+1);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.Text := '';
NmUDP1.ReportLevel := Status_Basic;
end;
procedure TForm1.NMUDP1DataReceived(Sender: TComponent;
NumberBytes: Integer; FromIP: String; Port: Integer);
var
Txt
char;
Count:Integer;
begin
GetMem(Txt,NumberBytes+1);
ZeroMemory(Txt,NumberBytes+1);
NMUDP1.ReadBuffer(Txt^,Count);
Memo1.Lines.Add(Txt);
end;
end.