unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, IdSocketHandle, IdBaseComponent, IdComponent, IdUDPBase, IdUDPServer, Vcl.StdCtrls; type TForm1 = class(TForm) IdUDPServer1: TIdUDPServer; Memo1: TMemo; procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure IdUDPServer1UDPRead(AThread: TIdUDPListenerThread; AData: TBytes; ABinding: TIdSocketHandle); private { Private declarations } public { Public declarations } end; var Form1: TForm1; MyUDPMessage : String; implementation {$R *.dfm} function BytesToString(bytearray: array of byte; len : Integer): String; var a: Integer; begin result := ''; for a := 0 to len-1 do begin result := result + char(bytearray[a]); end; end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin Form1.IdUDPServer1.Active := False; end; procedure TForm1.FormCreate(Sender: TObject); begin Form1.IdUDPServer1.DefaultPort := 3333; Form1.IdUDPServer1.Active := True; Form1.IdUDPServer1.OnUDPRead := IdUDPServer1UDPRead; end; procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread; AData: TBytes; ABinding: TIdSocketHandle); begin MyUDPMessage:=BytesToString(AData,10240); Memo1.Lines.Add(MyUDPMessage); end; end.
Wednesday, 8 November 2017
read UDP messages
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...
c程序员的代码示例
ReplyDelete使用terminfo数据库示例代码