Note that there are some explanatory texts on larger screens.

plurals
  1. POWinforms Downloading Large Files Socket Error On XP
    primarykey
    data
    text
    <p>I am having an issue with my client app downloading a large binary file from our webservice. Note that this does not occur on any other machines running higher OS's, and it does not occur for most smaller file sizes. For whatever reason, the app fails within the first While loop, and no amount of googling has helped thus far.</p> <p>The code:</p> <pre><code>Try Dim strWebRequestUrl As String = (url ommited) Dim fileSize As Int64 = Nothing Dim reqDownload As HttpWebRequest = HttpWebRequest.Create(strWebRequestUrl) Dim resDownload As HttpWebResponse = reqDownload.GetResponse Dim streamDownload As Stream = Nothing Dim bytesToRead As Int64 = Nothing Dim totalBytes As Int64 = Nothing Dim bytesRead As Int64 = Nothing Dim saveLocation As String = Nothing Dim saveExt As String = resDownload.GetResponseHeader("EXTENSION") Dim fstr As FileStream = Nothing Dim downloadPercent As String = "0%" fileSize = resDownload.ContentLength 'This is just logging stuff: StrDebugStatus = "Step_Row_ID downloaded file size: " &amp; fileSize LogDebug(StrDebugStatus) streamDownload = resDownload.GetResponseStream Dim inBuf(fileSize) As Byte bytesToRead = CInt(inBuf.Length) totalBytes = CInt(inBuf.Length) bytesRead = 0 While bytesToRead &gt; 0 Dim n As Int64 = streamDownload.Read(inBuf, bytesRead, bytesToRead) If n = 0 Then Exit While End If bytesRead += n bytesToRead -= n downloadPercent = FormatPercent(bytesRead / totalBytes, 0) StrAppStatus = bytesRead &amp; "b" &amp; " | " &amp; downloadPercent LogMe(StrAppStatus) End While </code></pre> <p>Then it goes on to write the file. Writing the file is not the issue, it errors within the first loop through the While statement... Again, this ONLY happens on files greater than approximately 100mb., and ONLY on XP machines... Any help would be hugely appreciated.</p> <p>Here is the output of the error that gets saved to my log file when it occurs:</p> <p>7/19/2013 10:15:02 AM | Step_Row_ID downloaded file size: 134246639</p> <p>7/19/2013 10:15:02 AM | 2594b | 0%</p> <p>7/19/2013 10:15:02 AM | Error attempting to download report from Step_Row_ID: 4533: Unable to read data from the transport connection: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full. | System.Net.Sockets.SocketException: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)</p> <p><strong>EDIT:</strong> As an update, this code works for a filesize like this with no problem:</p> <p>7/19/2013 1:23:32 PM | Step_Row_ID 4540 download complete: | 29257728b read</p> <p>But with the large filesize listed above, every time it attempts to download, it fails after different amounts of bytes (see the log below, and look at log above, different byte count yet same failure...):</p> <p>7/19/2013 1:23:38 PM | Step_Row_ID downloaded file size: 134246639b</p> <p>7/19/2013 1:23:38 PM | 3770b | 0%</p> <p>7/19/2013 1:23:38 PM | 12814b | 0%</p> <p>7/19/2013 1:23:38 PM | 25954b | 0%</p> <p>7/19/2013 1:23:38 PM | 28658b | 0%</p> <p>7/19/2013 1:23:38 PM | Error attempting to download report from Step_Row_ID: 4533: Unable to read data from the transport connection: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full. | System.Net.Sockets.SocketException: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload