Results 1 to 2 of 2

Thread: Binary Data with Winsock GetData

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2001
    Posts
    2

    Binary Data with Winsock GetData

    I am trying to receive binary data via UDP using the Winsock control's GetData method within the DataReceived event procedure. When I use a string variable to receive text, my program works. But when I use a byte array, no data is placed in the byte array.

    Here is the code for receiving into a string:

    Dim a as String
    WinsockCtl.GetData(a)
    MsgBox(a) ' displays received data

    For the byte array:

    Dim b(1024) as Byte
    WinsockCtl.GetData(b, vbByte + vbArray)
    ' all elements of b contain zero

    What am I doing wrong?

    Thanks

  2. #2

    Thread Starter
    New Member
    Join Date
    May 2001
    Posts
    2

    Smile

    I solved my own problem on this one. The byte array needs to be a dynamic array that is redimensioned to the length of the received data. If the receiving variable is not equal to the length of the received data, GetData returns no data.

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