|
-
Jul 13th, 1999, 05:45 PM
#1
Thread Starter
New Member
I have a simple server/client program set up using MS Winsock Control 2.0 and VB5. Up until now, everything has been working fine. The server has an array of winsock controls, and listens for connections on the 0-th control, then assigns connections dynamically to new controls. Nothing new there. There is also a series of commands that the server can send the client and visa versa.
Now here is the problem I'm having. Say there are three clients connected. Normally everything functions as I expect, with each client getting the proper command responses to each of its commands. However, if I ever try to send the same command to all clients (from the server), only the first client gets the command immediately. The other clients get the command only AFTER they request another command from the server, and the server replies.
So for example, if I'm running the server and I tell it to send a message to all clients like "HI"... the server loops through each active winsock control, and sends that data. However, only the first client gets the command. Clients 2 and 3 just sit there. Now, say I have client 2 send a command to the server, to which the server replies "HI" again. Now client 2 gets BOTH of the "HI" messages at once.
Does anyone have any idea why this happens or how to fix it? The problem appears to be limited to when I try to send the same data to different winsock controls from within a loop.
Thanks!
Kirk Hemmen
[email protected]
-
Jul 15th, 1999, 05:53 PM
#2
New Member
You need to add a DoEvents.
I had this same problem and found that adding a DoEvents in the loop fixes it.
For i = tcpServer.LBound To tcpServer.UBound
If tcpServer(i).State = sckConnected Then
tcpServer(i).SendData OutGoingMsg
DoEvents
End If
Next
Hope that helps.
Bryan
-
Jul 17th, 1999, 12:49 AM
#3
New Member
How do you guys make an array of winsock controls? I have figured out how to do Client Server stuff with winsock, but I've wondered how to do a true Server with multiple clients. You guys say an array of winsock controls; can I have an example? Thanks
-
Jul 19th, 1999, 07:29 AM
#4
New Member
Bryan,
I am working with cm on the same project, and we tried adding a DoEvents call right after we call SendData. This did not work. We still have problems with the first client not getting the message that we send it. Any idea where we could get help from MS on this one?
How did you figure out to put a DoEvents in your code? Did someone tell you, or did you call support?
Thanks,
Jake
-
Jul 19th, 1999, 09:45 AM
#5
Thread Starter
New Member
chiahawk:
just start up Visual Basic Books Online, and type in winsock. It has a pretty good example of how to set up a server that can support multiple clients. You can just expand from there.
Bryan:
mag_ is right, we tried the DoEvents command right after invoking the SendData method to no avail. I plan to tinker with it more tomorrow, as I only got a chance to try it real quick today, but I'm not optimistic. I've tried it with both VB5 SP3 and VB6 SP3. Which version/service pack were you running under when you corrected the problem by using DoEvents?
Kirk
-
Jul 22nd, 1999, 07:46 AM
#6
Member
i had the same problem with my server/client software. all i did to fix it was add DoEvents right after the SendData command. i'm on vb5 w/ sp3
------------------
-FirePoweR-
[email protected]
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
|