Reading raw data from a socket

I have a device that sends data to my server via gprs. The problem is that it sends raw data, and I don't know where I can stop reading

I am currently using something like TIdHttpServer and something like this to read lines:

var
    s : string;
    repeat
       s:=s+acontext.Connection.Socket.ReadChar;
    until acontext.Connection.Socket.InputBufferIsEmpty;

Is there a better solution to my problem?

+3
source share
2 answers

TCP is flow oriented. If the protocol is unknown, the server may try to read in a byte array (if memory is not a problem) or a file stream. If the client disconnects normally, the data is "completed". Unfortunately, if the protocol is unknown, the server cannot report that the client is dead or disconnected normally.

InputBufferIsEmpty , , (TCP) - , , .

"" , . , - "escape" ..

+3

.

:

  • .
  • -
0

All Articles