 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Robert T Guest
|
Posted: Sun Sep 04, 2005 9:30 am Post subject: Socket.ReadText |
|
|
Hi
I Send Specific messages that trigger procedures on my remote computer.
The problem I am getting is that sometimes the readtext returns 2 messages
in one ie : Remote pc sends "Waiting For Completion" and "Confirmed".
Readtext gets "Waiting For CompletionConfirmed"
procedure TftpForm.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var
AnswerText : String;
begin
AnswerText := Socket.ReceiveText;
GenerateResponse(AnswerText);
end;
How can I prevent this?
Thanks
|
|
| Back to top |
|
 |
Martin James Guest
|
Posted: Sun Sep 04, 2005 10:03 am Post subject: Re: Socket.ReadText |
|
|
TCP transfers a stream of bytes. If you send a 100 byte buffer, this could
be recieved as one 100-byte buffer, 100 1-byte buffers or anything in
between. Similarly, if you send 100 1-byte buffers, it could be received as
a single 100-byte buffer.
You need another protocol on top of TCP if you wnat to send lines of text
and receive/process them as individual lines. Adding a CRLF at then end of
each send string and using 'ReadLn' at the receive end is one common way.
Rgds,
Martin
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|