Winsock byte array - need crash course *resolved
Here's the code that sends the data.
VB Code:
'This part is in another procedure
Select Case Left(strData, 20)
Case CM_QUERY_HOSTINFO
strSendData = CM_QUERY_HOSTINFO
Call SendData_sckTCP(SocketIndex, strSendData)
MsgBox frmMainCommon.sckTCP(SocketIndex).State
If IntVar.Flag_IsServer = True Then
strSendData = CM_INFO_SERVERINFO & HostInfo_Local.B_UCDHostname
Call SendData_sckTCP(SocketIndex, strSendData)
Else
strSendData = CM_INFO_LOCALINFO & HostInfo_Local.B_UCDHostname
Call SendData_sckTCP(SocketIndex, strSendData)
End If
'This the generic send procedure
Public Sub SendData_sckTCP(SocketIndex As Integer, strSendData As String)
'Procedure Description:
'
Dim Counter_SendAttempts As Byte
Dim strIPAddress_tmp As String
Counter_SendAttempts = 0
strIPAddress_tmp = ""
On Error GoTo Error_Handler 'Enable error handler
frmMainCommon.sckTCP(SocketIndex).SendData strSendData
On Error GoTo 0 'Disable error handler
Exit Sub 'Exit function on successful send.
Error_Handler:
Counter_SendAttempts = Counter_SendAttempts + 1
If Counter_SendAttempts = MaxRetry_Send Then
strIPAddress_tmp = IndexToIP_HostInfo_Array(SocketIndex)
MsgBox "Unable to send data to remotehost " & Trim(strIPAddress_tmp) & "." _
& vbCrLf & vbCrLf _
& "sckTCP(" & SocketIndex & ") will be unloaded and the corresponding" _
& vbCrLf & "host information will be removed from:" & vbCrLf _
& " HostInfo_Array()" & vbCrLf _
& " LoadedsckTCP_Array()", _
vbOKOnly, "Error: SendData_sckTCP(" & SocketIndex & ")"
Call UnassignIndex_sckTCP(SocketIndex)
Call RemoveFrom_HostInfo_Array(strIPAddress_tmp)
Resume Next
Else
Resume 'Retry send.
End If
'Procedure Analysis:
End Sub
Instead of two data arrivals (which I had expected to happen);
"CM_QUERY_HOSTINFO "
"CM_INFO_SERVERINFO UC-Daisy "
I got "CM_QUERY_HOSTINFO CM_INFO_SERVERINFO UC-Daisy "
WHERE DID I GO WRONG! *sniff
Is there anyway to make it two data arrivals? I want to avoid dealing with a stream as much as possible.
Because if I do, I have to check amount of bytes before send, send that info along with the packet, parse the stream at the other end according to this, and so on and so forth... :( *sniff
Can I use SendComplete in the solution, if so how?