Why TClientSocket.OnRead event fires two times for a single server send

So, I have a TClientSocket which have to receive over 10KB of data in one OnRead event. But when the event is triggered it only gets 8KB of data, then the event fires again with the rest of the data.

Why is this happens?

Answers


Because TCP is a stream protocol, not message-based. You must receive whatever you have been sent, merge it to one stream of data, then parse the stream according to used protocol.


You need to write a server-client agreed protocol that will signal the end of the message nad by that to parse the streaming to complete messages.


Need Your Help

Display a “Select” element in JQGrid

jquery jqgrid

I'm aware of the editype="select" option, however, in order to see the Select, the user has to initiate an editing.

CDbCriteria conditions and params

php mysql sql yii

This is the first time I try to use CDbCriteria so I should have a concept error, I have the next function in the class AsistenciasUtils:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.