BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Socket.ReadText

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
Robert T
Guest





PostPosted: Sun Sep 04, 2005 9:30 am    Post subject: Socket.ReadText Reply with quote



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





PostPosted: Sun Sep 04, 2005 10:03 am    Post subject: Re: Socket.ReadText Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.