Link to home
Start Free TrialLog in
Avatar of Gamemaster328
Gamemaster328

asked on

VB6: Winsock Trivia Game Problem

i made a trivia game for a friend. basically, the server sends questions to all the clients and who ever answers them first, gets a point. the problem is, sometimes winsock sends data a the same time. also, when the client disconnects, then tries to reconnect again, the server gets an error. i dont want to use "on error resume next" because that sometimes causes complications. is there any way to fix this winsock problem?

my code for sending data is

for a = 1 to wsk.ubound
  if wsk(a).state = sckconnected then
    wsk(a).senddata strData
  end if
next a

now, it send the data correctly, but sometimes it sends them at the same time, and the String gets combined together.

------------------------------------------
Sub 1:
strData = "Chat///Goodbye World"
for a = 1 to wsk.ubound
  if wsk(a).state = sckconnected then
    wsk(a).senddata strData
  end if
next a

Sub 2:
strdata = "Com///Hello world"
for a = 1 to wsk.ubound
  if wsk(a).state = sckconnected then
    wsk(a).senddata strData
  end if
next a
------------------------------------------

when the client receives the data, it gets this:
"Chat///Goodbye WorldCom///Hello World".

could someone please help? if someone needs the source for both client and server, i would upload somewhere. thank you!
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

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
Avatar of Gamemaster328
Gamemaster328

ASKER

wow. that was amazing! it worked well. thank you. i changed /// to chr(1) and the end delimiter to chr(5) i havn't tested what all chr()s are, but im pretty sure i will be using more and more of the chr functions. =) thank you!