Results 1 to 2 of 2

Thread: Passing array via winsock

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    Austin Texas
    Posts
    1

    Unhappy

    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
    Jason Johndrow
    [email protected]

  2. #2
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177
    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...
    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.
    Code:
    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:
    Code:
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width