UDP Can I send two parts of a datagram and make the receiving end a combination of them?

This may be a dumb question, but since I'm relatively new to UDP, it goes here ... If I have two separate byte arrays, I need a receiver to get as one big array, for example:

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

Can I create a buffer and copy each array into it, and then send this buffer, for example:

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 large and the data transfer speed is high, copying uses a lot of system resources ... Can I somehow tell udpClient that I start UDP fragmentation and then do like this:

udpClient.ImStartingOneBigDatagram();

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

udpClient.ThatsAllFolks();

And make sure that the receiving party will receive:

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

I use C # for this, and I do not need to use UdpClient, I just did my thought.

+5
2

Win32 API WSASendMsg:

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

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

, , , - 9 . , .. (4 x86), , API , .

+2

, UDP-. UDP , . , ? , , -, UDP.

, " , ..." - . UDP, , -.

, , , , -, UDPclient udpclient.Send(), .ThatsAllFolks -. , Big Send. .

+2

All Articles