?? main.pas
字號:
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdUDPBase, IdUDPServer, IdSocketHandle,
StdCtrls;
type
TForm1 = class(TForm)
IdUDPServer: TIdUDPServer;
edInfo: TEdit;
Label1: TLabel;
Label2: TLabel;
lbBytes: TLabel;
btnListen: TButton;
edPort: TEdit;
procedure IdUDPServerUDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
procedure btnListenClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.IdUDPServerUDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
var
Buf : array[1..1024] of char;
Str : string;
Len : integer;
begin
FillChar(Buf, SizeOf(Buf), 0);
Len := AData.Read(Buf, 1000);
Str := String(Buf);
SetLength(Str, Len);
edInfo.Text := Str;
lbBytes.Caption := IntToStr(Len);
end;
procedure TForm1.btnListenClick(Sender: TObject);
begin
IdUDPServer.DefaultPort := StrToInt(edPort.Text);
IdUDPServer.Active := True;
btnListen.Enabled := False;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -