B, definitely.
You can do something like "A", but it means you're allocating a big chunk of
memory, which is expensive (both in memory use and perf, since you will
flush your cache away when you traverse it). There's also the disadvantage
of having the receiver block on a read for a *long* time (could be 3 minutes
to send 10MB over a 10Mbps ethernet link (assuming I did my math
correctly)). You also might want to be able to restart the transfer if it
got interrupted for some reason.
Finally, the data is going to be chunked into smaller pieces when it goes
over the network anyway. My advice is to pick something reasonable
(something like 4K seems like a good starting point), and then benchmark to
see whether that's a good choice.
--
Eric Gunnerson
Visit the C# product team at
http://www.csharp.net
Eric's blog is at
http://blogs.gotdotnet.com/ericgu/
This posting is provided "AS IS" with no warranties, and confers no rights.
"AA" <aa@personal.net.py> wrote in message
news:ew**************@TK2MSFTNGP11.phx.gbl...
I am writing a socket class that implements the System.Net and
System.Net.Sockets namespaces.
My Question is:
If I need to send a large amount of data through a socket connection (for
example 10MB) which option is better?
A) put all 10MB together in 1 Byte Array and pass it to the Send function
B) create small arrays with less data and send each one by one (which
could be the better size if you think that this option is the correct)
C) Another suggest?
Thanks a lot