Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21281

Is this the correct way to receive a byte array? Is there a better way?

$
0
0
I have this code to receive a byte array sent from a Winsock connection. It works but I was wondering if it is the correct way to do it or if there is a better way.

Code:

Private MyByteArray() As Byte
  '
  '
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
 Static ArryStart As Long
 Static TotalAccumBytes As Long

 Dim byteArr() As Byte
 Dim vta
 
 TotalAccumBytes = TotalAccumBytes + bytesTotal
 
 ReDim Preserve MyByteArray(TotalAccumBytes)
 
 Winsock1.GetData vta, vbArray + vbByte
 byteArr = vta
 
 For n = 0 To UBound(byteArr)
  MyByteArray(ArryStart) = byteArr(n)
  ArryStart = ArryStart + 1
 Next n
End Sub
  '
  '


Viewing all articles
Browse latest Browse all 21281

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>