Results 1 to 8 of 8

Thread: Winsock byte array - need crash course *resolved

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Winsock byte array - need crash course *resolved

    Here's the code that sends the data.

    VB Code:
    1. 'This part is in another procedure
    2.     Select Case Left(strData, 20)
    3.     Case CM_QUERY_HOSTINFO
    4.         strSendData = CM_QUERY_HOSTINFO
    5.         Call SendData_sckTCP(SocketIndex, strSendData)
    6.        
    7.         MsgBox frmMainCommon.sckTCP(SocketIndex).State
    8.         If IntVar.Flag_IsServer = True Then
    9.             strSendData = CM_INFO_SERVERINFO & HostInfo_Local.B_UCDHostname
    10.             Call SendData_sckTCP(SocketIndex, strSendData)
    11.         Else
    12.             strSendData = CM_INFO_LOCALINFO & HostInfo_Local.B_UCDHostname
    13.             Call SendData_sckTCP(SocketIndex, strSendData)
    14.         End If
    15.  
    16.  
    17. 'This the generic send procedure
    18. Public Sub SendData_sckTCP(SocketIndex As Integer, strSendData As String)
    19. 'Procedure Description:
    20. '
    21.  
    22.     Dim Counter_SendAttempts As Byte
    23.     Dim strIPAddress_tmp As String
    24.    
    25.     Counter_SendAttempts = 0
    26.     strIPAddress_tmp = ""
    27.    
    28. On Error GoTo Error_Handler 'Enable error handler
    29.     frmMainCommon.sckTCP(SocketIndex).SendData strSendData
    30.  
    31. On Error GoTo 0             'Disable error handler
    32.     Exit Sub                'Exit function on successful send.
    33.  
    34. Error_Handler:
    35.     Counter_SendAttempts = Counter_SendAttempts + 1
    36.     If Counter_SendAttempts = MaxRetry_Send Then
    37.        
    38.         strIPAddress_tmp = IndexToIP_HostInfo_Array(SocketIndex)
    39.         MsgBox "Unable to send data to remotehost " & Trim(strIPAddress_tmp) & "." _
    40.             & vbCrLf & vbCrLf _
    41.             & "sckTCP(" & SocketIndex & ") will be unloaded and the corresponding" _
    42.             & vbCrLf & "host information will be removed from:" & vbCrLf _
    43.             & "     HostInfo_Array()" & vbCrLf _
    44.             & "     LoadedsckTCP_Array()", _
    45.             vbOKOnly, "Error: SendData_sckTCP(" & SocketIndex & ")"
    46.            
    47.         Call UnassignIndex_sckTCP(SocketIndex)
    48.         Call RemoveFrom_HostInfo_Array(strIPAddress_tmp)
    49.        
    50.         Resume Next
    51.     Else
    52.         Resume  'Retry send.
    53.     End If
    54.    
    55. 'Procedure Analysis:
    56. 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?
    Last edited by leinad31; Feb 14th, 2003 at 11:38 AM.

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