发数据包,发送成功则计算一次,否则不计算.
计算的结果放在数据包udpBuffer[1]里.
这怎么做呢?
function TFrm_Main.SendSetRemoteIPCmd(f_strIP: string; f_nPort: integer): boolean;
var
udpBuffer: TBytes;
begin
result := false;
// 状态查询指令
setlength(udpBuffer, 60);
udpBuffer[0] = $01 // 发送指令数据
try
IdUdpClient1.Host := f_strIP;
IdUdpClient1.Port := f_nPort;
IdUdpClient1.SendBuffer(udpBuffer);
result := true; except
On E: Exception do
EventRecord('向 ' + f_strIP + ' 发送更改远端设备IP地址指令 Err=' + E.Message);
end;
end;
end;
计算的结果放在数据包udpBuffer[1]里.
这怎么做呢?
function TFrm_Main.SendSetRemoteIPCmd(f_strIP: string; f_nPort: integer): boolean;
var
udpBuffer: TBytes;
begin
result := false;
// 状态查询指令
setlength(udpBuffer, 60);
udpBuffer[0] = $01 // 发送指令数据
try
IdUdpClient1.Host := f_strIP;
IdUdpClient1.Port := f_nPort;
IdUdpClient1.SendBuffer(udpBuffer);
result := true; except
On E: Exception do
EventRecord('向 ' + f_strIP + ' 发送更改远端设备IP地址指令 Err=' + E.Message);
end;
end;
end;
1、定义好错误数值在包中的位置及编码长度和格式等;
2、定义一个全局变量统计错误次数。