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

  • SEARCH
  • Home
  • 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 6603093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:57:42+00:00 2026-05-25T18:57:42+00:00

When the callback assigned by Socket.BeginReceive() gets some bytes, what is the best way

  • 0

When the callback assigned by Socket.BeginReceive() gets some bytes, what is the best way to know I have the whole message? Should I have the first 4 bytes of each message I send hold the length of the message?

I am sending an XML file in each message so there is no unique character I can use as a message separator.

  • 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-05-25T18:57:43+00:00Added an answer on May 25, 2026 at 6:57 pm

    I would use a header containing two integers (4 bytes each). The first one would indicate protocol version and the second one would indicate message length. The good thing with using a header length instead of a delimiter is that you can allocate a buffer for the entire message before you start parsing it.

    Using a version integer as the first header let’s you change the rest of the headers, and the body, in any newer version of the protocol.

    Update in reply to the comment

    There is a difference between version number in the header and the one in the actual message. The message version is for the document, but the header version is for the protocol itself. By using a protocol version you could switch message transport from XML to Protobuf or something else for the message. You could also add a header identifying the target of the actual message.

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

Sidebar

Related Questions

I have a set of callback classes that I use for handling callbacks with
I have a webservice that when called without specifying a callback will return a
We're using an asp:TreeView configured with lazy loading. The callback method assigned for OnTreeNodePopulate
I have a for loop, and inside it a variable is assigned with var.
what would be best way to handle simple text styles like bbcode allowing bold
I have an AJAX callback that returns a list of results that are written
Why are async callback socket methods usually static? (assume I understand static class, method
I have to design and implement a way to deal with long running processes
i have a problem using a jqGrid, more specific the loadComplete callback event. When
I have this callback function setup: var contextMenu = []; var context = [

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.