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 393685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:16:55+00:00 2026-05-12T16:16:55+00:00

Whats the best way to format a message to a server, at moment I’m

  • 0

Whats the best way to format a message to a server, at moment I’m serilising an object using the binaryformatter and then sending it to the server.

At the server end its listening in an async fashion and then when the buffer size recieved is not 100% it assumes that the transfer has complete.

This is working and the moment, and I can deserialise the object at the other end, I’m just concerned that if I start sending async this method will fail has message’s could be blurred.

I know that I need to mark the message somehow as to say that’s the end of message one, this other bit belongs to message 2, but I’m unsure of the correct way to do this.

Could anyone point me in the right direction and maybe give me some examples?

Thanks

  • 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-12T16:16:56+00:00Added an answer on May 12, 2026 at 4:16 pm

    You could always serialize it to a memory stream, see how big it is, send the length as a 4-byte binary number then send the stream’s contents.

    On the other side you can just sit and wait for 4 bytes, combine them into an integer then sit and wait for that number of bytes.

    When your read function returns (make them blocking reads), you know you have the entire object into a buffer, so you just deserialize it and cast it to your common interface type.

    edit: this is the answer to your specific question. This being said you would be better off using a higher-level library than pure tcp.

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

Sidebar

Related Questions

What's the best way to return a Java Map using the JSON format? My
Whats the best way to zip up files using C#? Ideally I want to
Whats the best way to get the current time (HH:MM:SS) using Objective-C. I would
What is the best way to convert a string to DateTime? The format of
Whats the best way to check if a username exists in a MySQL table?
Whats the best way to read/write file properties (like author, description, etc) in C#?
Whats the best way to go about upgrading a project with major design changes...in
whats the best way to get Statistics Web pages by the users visited ?
Whats the best way to convert int's, long's, double's to strings and vice versa
What is the best way to format data? Here is the background : I

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.