What is the relationship between the Socket Buffer, the Read and Write Buffers, and the Message Queue?

What is the relationship between the Socket Buffer, the Read and Write Buffers, and the Message Queue?

book

Article ID: KB0084824

calendar_today

Updated On:

Products Versions
TIBCO SmartSockets -
Not Applicable -

Description

Resolution:
Upon RTclient initialization, the Read Buffer, Write Buffer, and Message Queue start out at a size of 8K. The Socket Buffer is a static 48K and is not tunable. The Read Buffer is not directly tunable but will grow to accommodate the size of the largest message read. The Message Queue will grow to accommodate the largest number of messages queued between message process calls.

Moving data from the Socket Buffer to the Read Buffer is accomplished using TipcSrvRead. TipcSrvRead calls TipcConnRead which moves all data (up to 48K) in the RTclient's Socket Buffer into the RTclient's Read Buffer.  A check is made to see if at least one message can be constructed from the data in the Read Buffer. If not (the message size > 48K), another call to TipcConnRead is made. Data continues to accumulate in the RTclient's Read Buffer until one message can be constructed. The message is then placed into the RTclient's Message Queue. In this way, the RTclient's Read Buffer can grow beyond its default 8K size. If a message 1MB in size is sent to RTclient, the Read Buffer will grow to accomodate this message size, continually reading 48K worth of data from the Socket Buffer until the message is completely read into the Read Buffer. The Message Queue will also grow to 1MB as the message is moved from the Read Buffer into the Message Queue. The Message Queue will continue to grow until you process the messages with TipcSrvMsgNext.

Example 1: Three reads where the message size is 1MB with no intervening process call will result in the Message Queue growing to 3MB. The size of the Read Buffer will remain at 1MB. The space allocated for the buffers will not be reclaimed until the RTclient is recycled.

Example 2: Assume the size of messages received was a constant 12K and 4 such messages were received. On one call to TipcSrvRead, the client would empty the Socket Buffer by moving 48K of data into the Read Buffer. From the Read Buffer 4 messages would be constructed and moved into the RTclient's Message Queue. A call to TipcSrvMsgNext pulls one message from the Message Queue to be processed; 4 calls to TipcSrvMsgNext would result in 4 processed messages before a fifth call to TipcSrvMsgNext would initiate a call to TipcSrvRead and the process of pulling data from the Socket Buffer and the construction of messages repeated.

The Write Buffer is tunable (see the setopt for RTclient SERVER_AUTO_FLUSH_SIZE). This buffer is initially 8K in size. As soon as the data in Write Buffer reaches SERVER_AUTO_FLUSH_SIZE, its contents will be flushed to the Socket Buffer and out to the corresponding connection (RTserver or RTclient). Setting SERVER_AUTO_FLUSH_SIZE to a value of 0 (zero) results in an immediate flush to the Socket Buffer anytime a write takes place. Setting this parameter to a higher value results in less flushing and less network traffic. It also provides more flexibility in allowing the application to push data at its discretion by making calls to TipcSrvFlush.



Issue/Introduction

What is the relationship between the Socket Buffer, the Read and Write Buffers, and the Message Queue?