JasonJ
Oct 11th, 2000, 09:18 AM
Can I pass an array across a winsock connection? Every time I try I get the error "Unsupported Variant Type".
I must be missing something
ccoder
Oct 11th, 2000, 10:31 AM
You have to convert it to one of VB's intrinsic data types. In this case, a byte array.
add the following to your code...
Private Declare Sub CopyMemory Lib "KERNEL32" _
Alias "RtlMoveMemory" (hpvDest As Any, _
hpvSource As Any, _
ByVal cbCopy As Long)
and then copy the array to a byte array.
i.e.
Dim bTBuff() As Byte ' buffer for sends/receives
ReDim bTBuff(Len(theArray))
CopyMemory bTBuff(0), theArray, Len(theArray)
tcpServer.SendData bTBuff
Lately, there have been a lot of posts on this topic. I have put together a small client/server example that passes a record back and forth. The record has the following structure:
Private Type dclLogRec
UserId As String * 8
PassWd As String * 8
UserOK As Integer
End Type
There are enough comments in the code to explain (I hope) what is happening and what you have to do to send/receive complicated data structures in VB. If anyone is interested, contact me and I will send the project in a zipped file.