Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Sending large files with Socket.SendPacketsAsync

$
0
0

Hi,

I was trying to use the System.Net.Socket.SendPacketsAsync method to send files but I get an error on files larger than 2GB. Then I tried to specify a file offset but only get 2 extra GB, for now being able to send 4GB files.

The reason is the Offset field in the System.Net.Socket.SendPacketsElement class is an Int32. However for representing a file offset it is often necesary an Int64 field. I checked out the internal structures that pass this value to native methods and in correspondency with accepted values from the Windows socket API, specifically the TransmitFile function, they are long fields.

Because of this, apparently the only restriction is in the interface provided by the System.Net.Socket.SendPacketsElement class.

This class tries to support both, buffers and files. Considering this, maybe the field size was restricted because byte arrays on a 32bit environment are limited to an Int32 max size but not a reason to kill functionality. Adding a new constructor overload and making the internal offset field a long value should be enough.

Is this restriction on purpose and why, or just a .NET issue?


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>