Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Winsock with VB

Posted on 1998-07-16
3
Medium Priority
?
279 Views
Last Modified: 2013-11-13
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
0
Comment
Question by:kylemann
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Author Comment

by:kylemann
ID: 1466018
Edited text of question
0
 
LVL 1

Expert Comment

by:brunchey
ID: 1466019
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.
0
 
LVL 6

Accepted Solution

by:
anthonyc earned 400 total points
ID: 1466020
Kyle,

Use DOEVENTS after each send, and it should work.  

Also, if you want to loop through a bunch of winsocks you can do this

dim x as winsock

for each x in winsock1()
   x.senddata "hi"
next x
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question