Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8410523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:11:58+00:00 2026-06-10T00:11:58+00:00

I’m looking at the advantages and disadvantages for two the different TCP message framing

  • 0

I’m looking at the advantages and disadvantages for two the different TCP message framing methods I’m aware of.

  1. Delimited: The TCP stream is broken into messages of a non fixed length by using a delimiter byte. When sending data the routine must check the message data for the delimiter and escape it to ensure safe transmission of the message frame. When receiving data the routine must read through the stream looking for the delimiter byte to break the frame into a message.

EG: User [Username]\nPassword [Password]\n

  1. Length-Prefixed: The TCP stream is broken into messages of a predetermined size by using a prefix of say 4 bytes to state the length of the message. When receiving data the routine will first read the prefix to determine the length of the message frame. When sending data the routine must prepend the length prefix to the message before transmission.

EG: [MessageLength]User [Username][MessageLength]Password [Password]

Both of these methods allow transmission of message frames that can vary in size and contain a stream of bytes to be interpreted. The higher level message structure or protocol is not relevant.


So I focus my attention towards scalability and performance efficiency. I find myself needing to run benchmark tests to see which method I can receive the greatest efficiency throughput without any message processing involved.


My current thoughts, I’m no expert by any means.

Delimited message frames would have lower efficiency during the receive routine as each byte in the stream needs to be checked for a message frame delimiter. Length-Prefixed message frames will always read the prefix bytes and the rest of the message frame stream will go straight into the buffer without processing until the entire message frame is received.

Where as Length-Prefixed message frames would have a lower efficiency during the send routine as the message prefix as to be transmitted before the message itself.


Other factors I can think could include:

  • Lots of small message frames would result in more packets being transmitted for a Length-Prefixed structure.
  • Lots of larger message frames would be process much more efficiently with a Length-Prefixed structure as each byte is not being read to check for a delimiter.

Any light across this topic would be awesome. I find it very hard to find good resources on the difference between Message Frame structures for TCP.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:12:00+00:00Added an answer on June 10, 2026 at 12:12 am

    From my experience length prefixing is preferred, the parsing code of messages tends to be easier to write.

    Besides, with message delimiters you need to figure out an escaping scheme if message payload may contain the delimiter character.

    I have come across a third scheme that is not payload agnostic. It defines different message types with known format, the different parts of the message may be either fixed or variable length. (Fixed for simple types and variable is arrays and strings). The structure is shared between client and server beforehand. When sending a message the message is prefixed with the message type number. From the message type number the receiving part can deduce how to parse the message.
    An example of this is the protocol for the LysKOM messaging system.
    This protocol has a formal specification that can be used to generate parser code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.