Results 1 to 2 of 2

Thread: winsock reliability...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Location
    KL Malaysia
    Posts
    64

    Talking

    Hey, my first question! Cool.

    Well, I am having problems with the reliability of the winsock control. Seems like when the network is slow, different packets of data combines. Since i have to decode the data to process for usage, some of the data got mixed up and generate a type mismatch error.

    For example, the program is supposed to send abc123 and def456 after that, the receiving side will get 'abc123def456'. My program crashes because of that. How can I ensure that the 2 packets go seperate?

    Thanks for any answers.

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Use something along the following lines :

    Code:
    Private Sub Winsock1_Connect()
        Winsock1.SendData "abc123"
        CanGo = True
    End Sub
    
    Private Sub Winsock1_SendComplete()
        If CanGo Then Winsock1.SendData "def456"
    End Sub
    Either that, or send some sort of control character, or characters along that pad the data. Then use split() when the data arrives. If the UBound of the array > 0, then data has been combined, and you can deal with it accordingly.

    - jamie
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

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