|
-
Feb 1st, 2006, 11:37 PM
#1
Thread Starter
Hyperactive Member
check if winsock is done loading?
is it possible to check when winsock is completely done loading? I want to display a msgbox saying "completed" when the WHOLE data is retrieved in the dataarrival.
here's what i would usually do:
---get data from dataarrival
---then
---if instr(text1.text, "done loading") ' "done loading" is the text at the end of the page
---msgbox "completed"
but it wont work this time, it's a bit hard to explain why, but is there another way of doing this?
-
Feb 2nd, 2006, 01:33 AM
#2
Re: check if winsock is done loading?
Normally I put something at the end of the data like you suggested.
Another way is to put the number of bytes to be transferred at the begining of the data.
What are you using to transfer the data?
-
Feb 2nd, 2006, 02:09 AM
#3
Re: check if winsock is done loading?
you can even use some chars as begin and end chars. like _S and _E for start and end of the string
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Feb 3rd, 2006, 01:45 AM
#4
Thread Starter
Hyperactive Member
Re: check if winsock is done loading?
 Originally Posted by moeur
Another way is to put the number of bytes to be transferred at the begining of the data.
do you have an example of this?
 Originally Posted by moeur
What are you using to transfer the data?
I'm using winsock, is that what you mean?
 Originally Posted by ganeshmoorthy
you can even use some chars as begin and end chars. like _S and _E for start and end of the string
I dont get what your saying.... Im totally confused
-
Feb 3rd, 2006, 01:51 AM
#5
Re: check if winsock is done loading?
are you using the Winsok control?
-
Feb 3rd, 2006, 01:59 AM
#6
Thread Starter
Hyperactive Member
Re: check if winsock is done loading?
yea im using the winsock control
-
Feb 3rd, 2006, 02:25 AM
#7
Re: check if winsock is done loading?
Originally Posted by moeur
Another way is to put the number of bytes to be transferred at the begining of the data.
do you have an example of this?
Just like you were doing with "done loading"
To Send the data just append the length of the data
Code:
Sub SendData(strData As String)
Dim strX As String
Dim HH As Byte
Dim MM As Byte
Dim LL As Byte
Dim lstring As Long
lstring = Len(strData)
LL = lstring And &HFF
MM = (lstring / &H100) And &HFF
HH = (lstring / &H10000) And &HFF
strX = Chr(HH) & Chr(MM) & Chr(LL) & strData
Winsock1.SendData strX
End Sub
When the data arrives just strip off that number
Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Static FullData As String
Static dataCount As Long
Dim strData As String
Winsock1.GetData strData
If dataCount = 0 Then 'get header
'let's asumme that the most data that will come in is < 15MB
'then 1st 3 bytes tell us how much data is coming
'assume format HH MM LL
dataCount = Asc(Mid(strData, 1, 1)) * &H10000 + _
Asc(Mid(strData, 2, 1)) * &H100 + _
Asc(Mid(strData, 3, 1))
FullData = Mid(strData, 4)
dataCount = dataCount - Len(FullData)
Else
FullData = FullData & strData
dataCount = dataCount - Len(strData)
End If
If dataCount <= 0 Then
MsgBox "Finished"
dataCount = 0
End If
End Sub
-
Feb 3rd, 2006, 02:29 AM
#8
Re: check if winsock is done loading?
Quote:
Originally Posted by ganeshmoorthy
you can even use some chars as begin and end chars. like _S and _E for start and end of the string
I dont get what your saying.... Im totally confused
to determine whether last bit of string is received at the end, you can check the special chars.. like if you are passing abcde then pass it like _Sabcde_E
and check for _E to confirm you have received the full string, instead of "done loading" and all, coz "done loading" could have been used by the user also within the string, so, you terminate the string with special chars like ^ or | or something else.
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|