|
-
Jan 3rd, 2001, 06:07 PM
#1
Thread Starter
New Member
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.
-
Jan 4th, 2001, 12:20 AM
#2
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
-
Jan 4th, 2001, 10:50 PM
#3
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|