使用 Delphi Indy 10.6 和 tcpclient 有什么方法可以告诉输入缓冲区中的数据格式

With Delphi Indy 10.6 and tcpclient is there any way to tell the data format in the input buffer

我正在传输小字节数据包和文件流。有什么方法可以判断传入的数据包实际上是一个文件流,还是对 IOHandler 来说都只是字节?

Is there any way to tell if the incoming packet is actually a file stream or does it all just look like bytes to the IOHandler?

就 IOHandler 而言,它只是原始字节。您有责任在您的应​​用程序代码中定义和实施协议,以控制数据包的结构和识别方式。例如,TL​​D(类型-长度-数据)是一种常见的协议惯用语,其中一个值标识正在发送的数据类型,后跟一个包含数据长度的值,然后是实际数据。