Link to home
Start Free TrialLog in
Avatar of kylemann
kylemann

asked on

Winsock with VB

After creating an array of winsock controls for multi-connection.accepts, I want to do a simple For Each loop to send a string of data.
For Each Player1 In colCurrentPlayers

   tcpChessServer(Player1.intPlayerIndex).SendData strAllPlayers

Next Player1
The problem is if I have multiple connections going when this code runs it sends the data inconsistently. One instance will read it right and another two may have missed it all together. Do I need to wait until each .SendData is complete before the loop continues???
Any VB source code dealing with Winsock would be greatly appreciated.
Thanks,
Kyle
Avatar of kylemann
kylemann

ASKER

Edited text of question
Yes, basically what you are doing here is asynchronous activities, meaning once you tell the winsock control to do something it does it, not waiting for anything else that you may want to do.  So yes, you need to wait until the .SendData method has completed to send the next one to make sure that it occurs.  I am sorry that I don't have any code for this as I have not used the winsock control for a while, but maybe there is an event in the control that you can run a loop statement that waits for some boolean variable to be changed in that event.
ASKER CERTIFIED SOLUTION
Avatar of anthonyc
anthonyc

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial