none
Sending large files with Socket.SendPacketsAsync RRS feed

  • Question

  • 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?

    Wednesday, March 19, 2014 10:32 AM

Answers

  • Hello,

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

    This is a restriction on purpose, .Net itself has no effect with the transaction, it is the limited of the TCP buffer, .net did not transfer files larger than this limit transmission segmentation. The buffer size has a max value which is described here, in fact, in the bottom of the socket transmit buffer is very small, so the transmission of a document to be issued a lot of packages, the amount of the packages is designed by person as MS team member, the reason may because of the limited transmission technology, so it is designed that it can only accept the known amount of packages, or maybe there are some others reason but they do not tell us.

    In a word, that is designed. It may be updated so that can accept the Int64 type parameter with the new version released.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, March 20, 2014 10:05 AM
    Moderator