?
Solved

VB6: Winsock Trivia Game Problem

Posted on 2004-09-28
2
Medium Priority
?
633 Views
Last Modified: 2013-11-12
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!
0
Comment
Question by:Gamemaster328
[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
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 12175048
Hi Gamemaster328,

What you need to do is create an end of message marker.  It looks you are using /// as a parameter delimiter which is a great start.  You need to the same thing for the end of a message so you you know when you have received a partial, entire or multiple messages in on DaraArrival event.

Below is a link to a chat system that demonstrates the idea.  In it I have used Chr(0) as a parameter delimeter and Chr(1) as a command delimeter.  Study the DataArrival() and processInputs() subroutines carefully.

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/VB_Controls/Q_20870693.html

Regards,

Idle_Mind
0
 

Author Comment

by:Gamemaster328
ID: 12186330
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!
0

Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

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

Author Cited: Konstantinos Dimopoulos URL Cited From: Article from Indie Games: http://indiegames.com/2012/07/browser_game_pick_the_grid.html The Grid (http://codeelf.com/games/grid/) is the sort of game I haven't played in over 10 years. It is …
Programming  of  forecasting lottery numbers for self use  on Turbo C++ is done by use of random number generator code by a program algorithm logic. Random numbers usually generates numbers between definite interval. Therefore, when entering the c…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

764 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