Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Socket.Receive isn't receiving everything.

Status
Not open for further replies.

mortgagedeveloper

Programmer
Sep 27, 2002
22
US
I can only receive small files < 20kb. Anything over that will stop about 1k bytes from being completely delivered. The code below shows the loop that should be receiving. The Receive method hangs without Blocking and throws an exception with Blocking on. nothing I have tried will accept the entire file transfer, any suggestions?
Thanks in advance.

While totalReceived < m_iFileLen

'clear out the buffer
Array.Clear(buffer, 0, buffer.Length)

'check if any errors occurred, timeout in 5 seconds
If Not skt.Poll(5000, SelectMode.SelectError) Then
Try
'receive next part of data being sent into the buffer
bytesReceived = skt.Receive(buffer, buffer.Length, SocketFlags.Partial)
Catch ex As SocketException
Exit While
End Try
totalReceived += bytesReceived

'write the bytes to the end of the new file in the correct folder
bw.Seek(0, SeekOrigin.Current)
bw.Write(buffer, 0, bytesReceived)
Else
Exit While
End If

End While
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top