G
gigglegile
Unregistered / Unconfirmed
GUEST, unregistred user!
unit uUDPServer;
interface
uses
SysUtils,classes,IdUDPServer, IdSocketHandle;
var
UDPServer:TIdUDPServer;
function setinfo(para1,para2:string):string;
type
MyControl=class(TComponent)
public
procedure MyUDPOnRead(Sender:TObject;AData:TStream;ABinding:TIdSocketHandle);
end;
implementation
procedure MyControl.MyUDPOnRead(Sender:TObject;AData:TStream;ABinding:TIdSocketHandle);
begin
//主要功能是监听从远程计算机发送过来的数据
end;
function setinfo(para1,para2:string):string;
begin
...
MyUDPOnRead;
...
end;
var
MyCtrl: MyControl;
initialization
begin
UDPServer:=TIdUDPServer.Create(Nil);
MyCtrl:=MyControl.Create(nil);
UDPServer.OnUDPRead:=MyCtrl.MyUDPOnRead;
end;
end.
1:我写的这个unit对不对??
2:因为在initialization中已经设置了UDPServer.OnUDPRead:=MyCtrl.MyUDPOnRead;在函数setinfo中可不可以不用写myUdpOnread过程??
3:initialization是不是表示任何一个工程调用这个单元里的函数时,就自动触发 initialization里面的事件!
interface
uses
SysUtils,classes,IdUDPServer, IdSocketHandle;
var
UDPServer:TIdUDPServer;
function setinfo(para1,para2:string):string;
type
MyControl=class(TComponent)
public
procedure MyUDPOnRead(Sender:TObject;AData:TStream;ABinding:TIdSocketHandle);
end;
implementation
procedure MyControl.MyUDPOnRead(Sender:TObject;AData:TStream;ABinding:TIdSocketHandle);
begin
//主要功能是监听从远程计算机发送过来的数据
end;
function setinfo(para1,para2:string):string;
begin
...
MyUDPOnRead;
...
end;
var
MyCtrl: MyControl;
initialization
begin
UDPServer:=TIdUDPServer.Create(Nil);
MyCtrl:=MyControl.Create(nil);
UDPServer.OnUDPRead:=MyCtrl.MyUDPOnRead;
end;
end.
1:我写的这个unit对不对??
2:因为在initialization中已经设置了UDPServer.OnUDPRead:=MyCtrl.MyUDPOnRead;在函数setinfo中可不可以不用写myUdpOnread过程??
3:initialization是不是表示任何一个工程调用这个单元里的函数时,就自动触发 initialization里面的事件!