I have some problem when using the Indy component ( idTCPServer ) to read the data sending by the client, the data itself was hexadecimal, so I can not use AThread.Connection.ReadLn (); for this...
Here are my sample data sent by the client
24 24 00 11 12 34 56 FF FF FF FF 50 00 8B 9B 0D 0A
or
24 24 00 13 12 34 56 FF FF FF FF 90 02 00 0A 8F D4 0D 0A
PS : it is in hexadecimal bytes (data length may vary depending on the command, maximum 160 bytes ), which cannot get a string representation, since $ 00 is translated to null (which means that I can not use ReadLn)
Here is my sample code
procedure TfrmMain.IdTCPServerExecute(AThread: TIdPeerThread);
var
Msg : Array[0..255] of Byte;
begin
AThread.connection.ReadBuffer(Msg,SizeOf(Msg));
AThread.connection.WriteBuffer(Msg,MsgSize,true);
end;
, 255 , , ,
procedure TfrmMain.IdTCPServerExecute(AThread: TIdPeerThread);
var
Msg : Array of Byte;
MsgSize : integer;
begin
MsgSize := AThread.connection.ReadInteger;
SetLength(Msg, MsgSize);
AThread.connection.ReadBuffer(Msg,MsgSize);
AThread.connection.WriteBuffer(Msg,MsgSize,true);
end;
, ( )? - ?