HOWTO: Send and Receive UDT's Using the Winsock ControlID: Q152058
|
The Winsock control methods SendData and GetData send and receive data
through an argument declared of type variant. The following variant types
are supported:
Byte vbByte
Integer vbInteger
Long vbLong
Single vbSingle
Double vbDouble
Currency vbCurrency
Date vbDate
Boolean vbBoolean
SCODE vbError
String vbString
Byte Array vbArray + vbByte
The example uses the Winsock TCP client and server created in the following
Microsoft Knowledge Base article:
Q152057 HOWTO: Create & Use a Client/Server Using Winsock TCP
Controls
Prior to following this example, make sure you have at least built the
framework for the client and server discussed in the aforementioned
article. You will be required to make modifications to the DataArrival
Event subroutine and the SendData Command subroutine.
Private Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (_
hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
Private Type MyType
i As Integer
l As Long
s As String * 8
d As Double
End Type
Private Sub TCP1_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim vta
Dim mt As MyType
Dim bt() As Byte
TCP1(Index).GetData vta, vbArray + vbByte, 32
bt = vta
CopyMemory mt, bt(1), 32
Debug.Print mt.i; ","; mt.l; ","; mt.s; ","; mt.d
End Sub
Private Sub cmdSendData_Click()
Dim mt As MyType
mt.i = 99
mt.l = 33
mt.s = "abcd"
mt.d = 23.76
Dim bt(32) As Byte
Dim vtdata As Variant
CopyMemory bt(1), mt, 32
vtdata = bt
TCP1.SendData vtdata
End Sub
Keywords : kbnetwork kbAPI kbSDKPlatform kbVBp400 kbWinsock kbGrpNet
Version :
Platform :
Issue type :
Last Reviewed: March 10, 1999