J
Joshua Frank
Hi,
I'm getting the strangest problem trying to receive from a socket. I'm
downloading a huge file. When I loop, receiving until I get no bytes back,
it works fine. But I wanted to update a progress bar during this process,
so I added a notification delegate and I call this each time through:
Dim Ret As Integer, Buffer(1023) As Byte
Do
Ret = theSocket.Receive(Buffer)
If Ret > 0 Then
If m_DownloadToFile Then
m_FileStream.Write(Buffer, 0, Ret)
Else
m_Data = m_Data + ASCII.GetString(Buffer, 0, Ret)
End If
m_TransferredBytes = m_TransferredBytes + Ret
'if we have a notification
If Not Notify Is Nothing Then
'notify
Call Notify(Ret) <------this causes the problem
End If
End If
Loop Until Ret = 0
But when I do this, I start losing bytes. If I don't call the Notify
delegate, the file is something like 36MB. But if I call it, I seem to lose
data, and the file only winds up at about 21MB. This is kind of hard to
debug, so before rolling up my sleeves, I was wondering if anyone with
socket experience could spot the problem right off. Any help much
appreciated. Thanks.
Cheers,
--
Joshua Frank
Senior Systems Architect
Archimetrics, L.L.C.
"Add some SpArk to your stored procedure development."
(web) http://www.archimetrics.com
(email) mailto:[email protected]
(voice) (973) 727-1510
I'm getting the strangest problem trying to receive from a socket. I'm
downloading a huge file. When I loop, receiving until I get no bytes back,
it works fine. But I wanted to update a progress bar during this process,
so I added a notification delegate and I call this each time through:
Dim Ret As Integer, Buffer(1023) As Byte
Do
Ret = theSocket.Receive(Buffer)
If Ret > 0 Then
If m_DownloadToFile Then
m_FileStream.Write(Buffer, 0, Ret)
Else
m_Data = m_Data + ASCII.GetString(Buffer, 0, Ret)
End If
m_TransferredBytes = m_TransferredBytes + Ret
'if we have a notification
If Not Notify Is Nothing Then
'notify
Call Notify(Ret) <------this causes the problem
End If
End If
Loop Until Ret = 0
But when I do this, I start losing bytes. If I don't call the Notify
delegate, the file is something like 36MB. But if I call it, I seem to lose
data, and the file only winds up at about 21MB. This is kind of hard to
debug, so before rolling up my sleeves, I was wondering if anyone with
socket experience could spot the problem right off. Any help much
appreciated. Thanks.
Cheers,
--
Joshua Frank
Senior Systems Architect
Archimetrics, L.L.C.
"Add some SpArk to your stored procedure development."
(web) http://www.archimetrics.com
(email) mailto:[email protected]
(voice) (973) 727-1510