Sender
unit UnitUDPClientAndroid;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
IdBaseComponent, IdComponent, IdUDPBase, IdUDPClient,
FMX.Controls.Presentation, FMX.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
IdUDPClient1: TIdUDPClient;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
begin
with IdUDPClient1 do
begin
Host := '192.168.0.5';
Port := 69;
send('filename.txt');
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
IdUDPClient1.Active := true;
end;
end.
// -----------------------------------------------------------------------------------------------------------
Receiver
unit UnitServer;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IdComponent,
IdIPWatch, IdBaseComponent, IdUDPBase, IdUDPServer, FMX.Controls.Presentation,
FMX.ScrollBox, FMX.Memo, IdGlobal, IdSocketHandle;
type
TForm1 = class(TForm)
IdUDPServer1: TIdUDPServer;
IdIPWatch1: TIdIPWatch;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
procedure IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
const AData: TIdBytes; ABinding: TIdSocketHandle);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
MyUDPMessage : String;
implementation
{$R *.fmx}
procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Lines.Add(IdIPWatch1.LocalIP);
Form1.IdUDPServer1.DefaultPort := 69;
Form1.IdUDPServer1.Active := True;
Form1.IdUDPServer1.OnUDPRead := IdUDPServer1UDPRead;
end;
procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
const AData: TIdBytes; ABinding: TIdSocketHandle);
begin
MyUDPmessage := BytesToString(AData);
Memo1.Lines.Add(MyUDPMessage);
end;
end.
Subscribe to:
Post Comments (Atom)
zomok E-commerce system plan. Choose your online ordering system. No-risk 30 day free trial. Then USD 9/month. No credit card required.
zomok E-commerce system plan. Choose your online ordering system. No-risk 30 day free trial. Then USD 9/month. No credit card required. h...
-
Grows your business with zomok online ordering platform. Zero commission. Suitable for restaurants, kopitiam, food, groceries, pet supplie...
-
Complete TFTP Server example, using Indy components There are not many good TFTP server examples out there, so I wrote this example of...
No comments:
Post a Comment