• November 15, 2020
  • Admin
  • FAQs

The fastest way to do this is to use the RtlMoveMemory API call, as illustrated in the following example:

'In the General Declarations
Private Declare Sub CopyMemory Lib "KERNEL32" Alias
"RtlMoveMemory" (_ hpvDest As Any, hpvSource As Any, ByVal cbCopy
As Long)
Private Type TData
Data1 as String * 10
Data2 as String * 10
End Type
'In the procedure...
Public Sub SendTheData()
Dim TDataStream as TData
Dim bytData() as Byte
Dim hSocket as Long
 'Assuming gobjSocketQ has been instantiated and activated
 hSocket = gobjSocketQ.ConnectSock("TheHostToConnectTo", 80)
 TDataStream.Data1 = "12345Test1"
 TDataStream.Data2 = "12345Test2"
FAQs 11
 Redim bytData(Len(TDataStream))
 'Copy the data from the UDT to a byte array
 CopyMemory bytData(0), TDataStream, Len(TDataStream)
 'Ready to send the data using WinsockQ's SendData method
 gobjSocketQ.SendData hSocket, bytData()
End Sub