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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:25:09+00:00 2026-05-13T10:25:09+00:00

i would like some help with the following. this is to do with Asynchronous

  • 0

i would like some help with the following. this is to do with Asynchronous sockets.

from the sender:

string stringData = "Welcome to my server server server";
byte[] message1 = Encoding.ASCII.GetBytes(stringData);

//MessageBox.Show(message1.Length.ToString());

client.BeginSend(message1, 0, message1.Length, SocketFlags.None, new AsyncCallback(SendData), client);

here as can be seen, the message.length can be found.

—

on the client:

  Socket remote = (Socket)iar.AsyncState;
  int recv = remote.EndReceive(iar);
  string stringData = Encoding.ASCII.GetString(data, 0, recv);

my question is is there a way to access the actual length of the sent data and based on that call recieve data until the complete message is recieved?

  • 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-13T10:25:10+00:00Added an answer on May 13, 2026 at 10:25 am

    No – TCP/IP is a stream protocol. Just because you’ve sent the data with one call doesn’t mean it will be sent as one packet, or that it won’t be merged with other packets. In other words, sending “X” then “Y” is equivalent to sending “XY” – they may well be transmitted with the exact same packets, indistinguishable to the other end.

    If you want the idea of an individual “message” in a stream, you should prefix the data with a few bytes explicitly stating its length. (An alternative is to use a delimiter, but I far prefer using a length prefix – it makes it easier to know how much data you’ve still got to receive, you don’t need to worry about starting to consume the next message, and you don’t have to worry about escaping the delimiter in some form.)

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

Sidebar

Ask A Question

Stats

  • Questions 268k
  • Answers 268k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I would just go with an object. It fits with… May 13, 2026 at 12:59 pm
  • Editorial Team
    Editorial Team added an answer Conceptually, in hardware these values are put into registers. In… May 13, 2026 at 12:59 pm
  • Editorial Team
    Editorial Team added an answer If you have a constructor for A which fills all… May 13, 2026 at 12:59 pm

Related Questions

I'd like some help with the following jQuery code if possible... $(document).ready(function() { $('table.sortable').each(function()
I need some help. Don't know if this is possible. I want to have
maybe anyone can help me out with my SELECT statement on MS SQL Server.
Would really appreciate some help with a search angine I'm trying to make for
I have the following question regarding Flex/AIR data grids: Can I access the value

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.