0

I was wondering if some one could provide an example on how best to send large files that could not fit in a reasonable buffer size that would require multiple sends to be read one as solid memory stream while using the SocketAsyncEventArgs architecture.

The best example I can find is here: C# SocketAsyncEventArgs handling receive and send data

But this is only going to turn the contents of one buffer into its own individual stream where as I need multiple sends consolidated into to one stream to be read as a whole.

Community
  • 1
  • 1
En'gai
  • 1
  • 5
  • You send method should be using Synchronous write. The Ethernet interface will handle splitting messages in to pieces. The read method should use Asynchronous method which will get messages in random sizes and must pack the data into a single byte[]. The receiver can get empty datagrams in the middle of a message so make sure your code doesn't stop when receiving a datagram with zero bytes. – jdweng Apr 18 '17 at 16:34
  • Are you saying that I can not send large files using AsyncEventArgs? – En'gai Apr 18 '17 at 16:43
  • No. There is really no need. There is very little difference Sync Send and Async Send to add the extra complexity in to the code. The Async Send Moves data from one buffer in the application to a 2nd buffer. The 2nd buffer hold data until Window operating system move data to Ethernet driverin pieces. When using Async the data still ends up waiting for Windows to move data to ethernet driver in same buffer. – jdweng Apr 18 '17 at 16:51

0 Answers0