Visual Basic
The Winsock control implements only the basic interface for accessing the Winsock API functions. Unlike the protocol-independent Winsock interface, the control can use only IP. In addition, it is based on the Winsock 1 1 specification and supports TCP and UDP protocols to a limited extent.
Private Sub wsClient_DataArrival(ByVal bytesTotal As Long)
Dim I As Long, msg As String, MsgID As String, MsgCode As ClientErrorCodes, MsgBody As String
msg = Space$(bytesTotal)
wsClient.GetData msg, vbString, bytesTotal
MsgBuff = MsgBuff & msg
Do
I = InStr(MsgBuff, vbNullCharDbl)
If I = 0 Then Exit Do
msg = Left$(MsgBuff, I - 1)
MsgBuff = Mid$(MsgBuff, I + Len(vbNullCharDbl))
If CurrentConnectState = ccsConnect Then
If ExtractDataString(msg, MsgID, MsgCode, MsgBody, Crypt) = dcrSuccess Then
If MsgID = EventMsgID Then
WinSock_Event (MsgCode), MsgBody
Else
WinSock_Processing MsgID, MsgCode, MsgBody
End If
End If
Else
If ExtractDataString(msg, MsgID, MsgCode, MsgBody) = dcrSuccess Then
ClientAuth_Recv MsgCode, MsgBody
End If
End If
Loop
End Sub
The ClientAuth_Recv function is called during the authorization process, the WinSock_Event and WinSock_Processing functions are called when receiving notifications and responses, respectively. These functions themselves are not given, since their contents will depend on the subsystem requirements. The WinSock_Event procedure receives the notification code and data. The WinSock_Processing procedure receives a message identifier (by which it will be possible to determine what the request was), the return code and the message content.
Source CODE >>
Visual Basic Source Code. TCP Client-Server
|