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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:12:54+00:00 2026-05-23T12:12:54+00:00

This is maybe a stupid question, but since I am relatively new to UDP

  • 0

This is maybe a stupid question, but since I am relatively new to UDP here it goes… If I am having two separate byte arrays that I need the receiving side to get as one big array, for example:

byte[] Array1 = {1,1,1}
byte[] Array2 = {2,2,2}

Can I avoid having to create a buffer and copy each array into it, and then send that buffer, like this:

byte[] Buffer= new byte[Array1.Length + Array2.Length];
Buffer.BlockCopy(Array1, 0, Buffer, 0, Array1.Length);
Buffer.BlockCopy(Array2, 0, Buffer, Array1.Length, Array2.Length);

udpClient.Send(Buffer, Buffer.Length);

Because if the two are big, and data rate is high, copying uses up much system resources…
So can I somehow tell the udpClient that I am starting the UDP fragmentation, and then do like this:

udpClient.ImStartingOneBigDatagram();

udpClient.Send(Array1, Array1.Length);
udpClient.Send(Array2, Array2.Length);

udpClient.ThatsAllFolks();

And be sure that the receiving side would get:

byte[] recv = {1,1,1,2,2,2}

I am using C# for this, and I dont need to use UdpClient, I was just making my point.

  • 1 1 Answer
  • 1 View
  • 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-23T12:12:54+00:00Added an answer on May 23, 2026 at 12:12 pm

    Use the equivalent of Win32 API’s WSASendMsg:

    public int Send(
        IList<ArraySegment<byte>> buffers,
        SocketFlags socketFlags,
        out SocketError errorCode
    )
    

    http://msdn.microsoft.com/en-us/library/ms145161.aspx

    But ultimately this is premature optimisation, if you perform some testing you will see that to use I/O scatter gather arrays you need at least 9KB of data to get performance improvement. For small buffers, i.e. less than a page size (4KB on x86) it is faster to build a contiguous buffer yourself before passing to the socket API.

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

Sidebar

Related Questions

Maybe this is stupid question, but I'd like to raise here since it's not
I've already posted this question here , but since it's maybe not that Qt-specific,
I'am new to jquery and maybe this is a stupid question but I have
Maybe its a stupid question, but i'm having this issue in Visual Studio 2010:
maybe this is a stupid question but : i run perl 5.8.8 and i
Well, maybe it is a stupid question, but I cannot resolve this problem. In
I know this maybe a stupid question but maybe I'm just confused with the
Maybe this is a very stupid question but... Why should I use tinytext and
Maybe this is a stupid question, but at the end of my pages i
I know maybe this is a stupid question, But i suck at sql But

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.