Difference between revisions of "TWSocket.LineLimit"

From Overbyte
Jump to navigation Jump to search
(first entry)
 
 
Line 13: Line 13:
 
If the client always sends data lines which end on CR/LF and the server shall display the lines individually in a memo, the server would set LineMode to true so that he always receives whole lines without needing to look for the end of a line himself.
 
If the client always sends data lines which end on CR/LF and the server shall display the lines individually in a memo, the server would set LineMode to true so that he always receives whole lines without needing to look for the end of a line himself.
  
 +
<syntaxhighlight lang="delphi">
 
   Socket.LineLimit:=100;            // prevent denial of service or buffer  
 
   Socket.LineLimit:=100;            // prevent denial of service or buffer  
 
                                     // overflows
 
                                     // overflows
Line 19: Line 20:
 
                                     // combination
 
                                     // combination
 
   Socket.LineMode:=true;
 
   Socket.LineMode:=true;
 +
</syntaxhighlight>
  
 
In [[TWSocket.OnDataAvailable|OnDataAvailable]] ReceiveStr is used to fetch the available data packet by packet.
 
In [[TWSocket.OnDataAvailable|OnDataAvailable]] ReceiveStr is used to fetch the available data packet by packet.

Latest revision as of 20:33, 1 July 2010

Main page -> ICS component reference -> TWSocket -> LineLimit

Definition

property LineLimit: integer;

Description

LineLimit defines the maximum length a message may have until the delimiter sequence must occur. If not set the sender might provoke a buffer overflow or something similiar.

Example

If the client always sends data lines which end on CR/LF and the server shall display the lines individually in a memo, the server would set LineMode to true so that he always receives whole lines without needing to look for the end of a line himself.

<syntaxhighlight lang="delphi">

 Socket.LineLimit:=100;             // prevent denial of service or buffer 
                                    // overflows
 Socket.LineEnd  :=chr(10)+chr(13); // the sender has to terminate all 
                                    // messages sent with this character 
                                    // combination
 Socket.LineMode:=true;

</syntaxhighlight>

In OnDataAvailable ReceiveStr is used to fetch the available data packet by packet.

Best practices

How to