Results 1 to 3 of 3

Thread: Winsock Problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Location
    Ohio
    Posts
    7
    When using the Winsock Control in VB6.. I have this problem..

    If I use a socket array.. Say Socket(1) socket(2) etc.. and I try to use something like a for next loop to send to all the connections..

    Example:
    For Q = 1 to 5
    Socket(Q).SendData "Whatever" & Vblf
    next

    It doesn't send to any but the last one (Socket(5)) .. However if after I do that .. And try sending something else to the single socket.. Lets say 3..
    Socket(3).SendData "Stuff" & VbLf
    Then It sends "Whatever" & Vblf & "Stuff" & VbLf

    I need it to send when its "Supposed" to... Not wait till it is called seperatly..

    Is there some kind of character.. Or command to make each send..

    Any help would be appreciated.

  2. #2
    Guest
    When you have mutliple SendData's in close together, like in a For Next loop the chances are the next SendData is excuted before the one before it finished sending, Winsock takes care of this by sticking the two together regardless and this gets you your missing results or weird strings. To solve this make use of the SendComplete event.

    Code:
    Dim Complete As Boolean
    
    Private Sub Form_Load()
        Complete = False
    End Sub
    
    Private Sub MySub()
        Dim i As Integer
    
        For i = 0 To 4
            Complete = False
            Winsock(i).SendData YourString
            Do Until Complete = True
                DoEvents
            Loop
        Next i
    End Sub
    
    Private Sub Winsock_SendComplete(Index As Integer)
        Complete = True
    End Sub
    This makes sure that the send finishes before the loop moves on.

    Sunny

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Location
    Ohio
    Posts
    7

    Thanks!

    Thank you so much!

    That has been bugging me for like the past 3 weeks. >.<

    Hehe, I can't believe I didn't think of that, Anyway.. Thanks again.

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