Winsock multi-client with vb
Well, I''m trying to make a multi-user chat client/server... I have it all connecting well... When a new user connects, the server sends a message to all the other clients saying theres a new user... But then when the clients try to chat, only the newest client recieves anything! I find that really strange... because I''m using the same code to broadcast a new client connection...
There must be something really stupid I''m doing... I''m guessing its something really simple... heh, any thoughts?
Are you connecting everyone to one winsock control? If so you have to send the message to every index of that control.
i.e Winsock(0).SendData to Winsock(LatestUser).SendData
If that''s not it, post your code
i.e Winsock(0).SendData to Winsock(LatestUser).SendData
If that''s not it, post your code
Yeah, I have a control array going... Heres my sub for sending messages... Its only in a sub because I needed it for my school project, lol
Sub SendToClients(TheData As String, TUsers as integer)
For i = 1 To TUsers
If Winsock1(i).State = sckConnected Then Winsock1(i).SendData TheData
Next i
End Sub
Like I said, Its working fine when it announces a new connection to everyone, but it only sends messages to the newest client. I''ve been reading the forums and it seems that TCP likes to let the messages pile up before sending... or something like that... Could this be it?
Sub SendToClients(TheData As String, TUsers as integer)
For i = 1 To TUsers
If Winsock1(i).State = sckConnected Then Winsock1(i).SendData TheData
Next i
End Sub
Like I said, Its working fine when it announces a new connection to everyone, but it only sends messages to the newest client. I''ve been reading the forums and it seems that TCP likes to let the messages pile up before sending... or something like that... Could this be it?
hahahaha! Thanks Ragonastick!!
http://gamedev.net/community/forums/topic.asp?topic_id=62016
That was soooo simple... I feel soooo dumb now, lol
---
I spelled his name wrong...
DoEvents in my for loop was all I needed btw
thanks for all your help guys
[edited by - branflakes29 on May 29, 2002 10:54:11 PM]
http://gamedev.net/community/forums/topic.asp?topic_id=62016
That was soooo simple... I feel soooo dumb now, lol
---
I spelled his name wrong...
DoEvents in my for loop was all I needed btw
thanks for all your help guys
[edited by - branflakes29 on May 29, 2002 10:54:11 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement