请问这样用idudpclient发送流对吗,怎样的写idudpserver接收函数(onudpread)才能接受回十六进制数呢?(100分)

  • 主题发起人 主题发起人 fatorhundan
  • 开始时间 开始时间
F

fatorhundan

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure Tfrmkeybroad.ZkPz(strzkIDAll: string; CommandType: string; strCode: string);
var
data: array[0..6] of int64;
datanumber: array[0..31] of integer;
DataStream : TmemoryStream;
begin
data[0] := $00EFCDAB;
datanumber[0] := 4;
datastream.WriteBuffer(data[0],4);
IdUDPClient1.SendBuffer(DataStream,DataStream.Size);
showmessage('baichi');
finally
DataStream.Free;
end;
end;
 
这样回来是不是可以?
procedure TForm1.IdUDPServer1UDPRead(Sender:TObject; AData:TStream;
ABinding:TIdSocketHandle);
var
DataStream:TMemoryStream;
begin
DataStream:=TMemoryStream.Create;
try
DataStream.CopyFrom(AData,AData.Size);
finally
DataStream.Free;
end;
end;
 
抱歉,前段时间上不了网,今天试了一下,我还想问问,如何用showmessage(‘’)把接收的数据转换成字符读出来,我做了,估计做法不行,请楼上继续指教,可以不 》?
 
procedure TForm1.IdUDPServer1UDPRead(Sender:TObject; AData:TStream;
ABinding:TIdSocketHandle);
var
LStr:String;
begin
LStr:=StrPas(PChar(AData.Memory));
Showmessage(LStr);
end;
 
AData.Memory在delphi7中通不过编译,adata有Memory的属性》?是否要转化为TCustomMemoryStream ?好像不行呀,晕。
 
Procedure TForm1.UdpServer1UDPRead(Sender: TObject; AData: TStream; ABinding: TIdSocketHandle);
Var
Ptr: Pointer;
data: array[0..6] of int64;
Begin
Try
Ptr := TMemoryStream(AData).Memory;
Move(ptr,Data,sizeof(data));
End;
End;
 
风铃夜思雨:有办法转为字符showmessage出来吗?头疼int64和字符
 
anyone can help me?或者结帖?
 
结帖了,以后的活自己想吧。。[?]
 
后退
顶部