
3-12
IM AQ6370C-17EN
strData = ""
Do
' data receive
DoEvents
Winsock1.GetData strData2, vbString
strData = s strData2
' Timeout check
sglNow = Timer()
If (sglNow < sglStart) Then sglNow = 86400
If sglNow >= sglEnd Then bTimeout = True
Loop While ((Right(strData, 1) <> vbLf) And (bTimeout = False))
' return value set
If bTimeout = True Then
ReceiveLan = -1
Else
ReceiveLan = Len(strData)
End If
End Function
'====================================================================
' Sub routine
' Recieve Binary query data
'
in:
none
'
out: byteArray
Receive data (byte array)
'
ret: Receive data size (Error: -1)
'====================================================================
Function ReceiveBinaryLan(byteArray() As Byte) As Long
Dim lngPos As Long
Dim lngTempPos As Long
Dim bData As Byte
Dim intI As Integer
Dim intJ As Integer
Dim strA As String
Dim lngDataLength As Long
Dim byteDummy() As Byte
Dim sglStart As Single
Dim sglEnd As Single
Dim sglNow As Single
Dim bTimeout As Boolean
sglStart = Timer()
sglEnd = sg TIMEOUT
bTimeout = False
'-------------------------------------------
' Header block
'-------------------------------------------
Call ReadIPBin(bData)
' Receive 1byte
If bData = Asc("#") Then
Call ReadIPBin(bData)
' Receive 1byte
intI = bData - Asc("0")
strA = ""
For intJ = 0 To intI - 1
Call ReadIPBin(bData)
' Receive 1byte
strA = strA + Chr(bData)
Next
intJ
lngDataLength = Val(strA)
' block data size
ReDim byteArray(lngDataLength)
3.3 Sample Program