fRemoteHost := pRemoteHost
//设置远程主机
fRemotePort := pRemotePort
//设置远程主机端口
fLocalPort := pLocalPort
//设置当前机器端口
NMUDP := TNMUDP.Create(nil);
NMUDP.RemoteHost := fRemoteHost;
NMUDP.RemotePort := strtoint(fRemotePort);
NMUDP.LocalPort := strtoint(fLocalPort);
NMUDP.ReportLevel := Status_Basic;
MyUDP := TMyUDP.Create;
MyUDP.Key := 55;
NMUDP.OnDataReceived := MyUDP.DataReceived;
NMUDP.OnStatus := MyUDP.MsgStatus;
type
TMyUDP=Class(TObject)
Public
Key:LongWord;
MyStatus:String;
Procedure DataReceived (Sender: TComponent
NumberBytes: Integer
FromIP: String
Port: Integer);
procedure MsgStatus(Sender: TComponent
status: String);
End;
procedure TMyUDP.DataReceived(Sender: TComponent
NumberBytes: Integer
FromIP: String
Port: Integer);
var
Codes:Array of Byte
//Codes为收到的数据流指针
Tmp:LongWord;
Msg:Array of Byte;
begin
Key := 88;
Exit;
Tmp := 0;
setlength(Codes,NumberBytes);
setlength(Msg,NumberBytes);
ReceiveMsgInfo((Sender as TNMUDP),Codes,Msg,NumberBytes);
CopyMemory(@Tmp,@Codes[0],4);
Key := Tmp;
end;
procedure TMyUDP.MsgStatus(Sender: TComponent
status: String);
begin
Mystatus := status;
end;
但是状态值和KEY值一直没有改变,也就是该时间没有触发,为什么?等待高手的回答,盼,盼