|
-
Jul 17th, 2007, 11:51 PM
#1
Thread Starter
New Member
[RESOLVED] Winsock data problem
Im building a client server app, everything works just fine the problem is that sometimes when i send multiple data to the server of from the servr to the client, the strings of two or more events overlap for example in form_load i request the server for the list of users and the list of online users at the same time so it would be:
Code:
winsock.senddata "/Userlist/"
doevents
doevents
winsock.senddata "/OnlineUsers/"
doevents
doevents
the problem is that somtimes the data arrives to the server as one string instead of two separate command, for example it arrives like:
"/Userlist//OnlineUsers/"... i thought that DoEvents would handle that but apparently it didnt, is there any other way i can take care of that... thnx
-
Jul 18th, 2007, 12:30 AM
#2
Re: Winsock data problem
That's a common problem, you have to check, the work around I used is checking each message received if it consists of more then one message. You need to have a characteristic ending sign to do that.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jul 18th, 2007, 01:12 AM
#3
Addicted Member
Re: Winsock data problem
Split Them
Example:
wsk.Senddata "NAME" & "/UserList/"
doevents
wsk.senddata "NAME" & "/OnlineUsers/"
on DataArrival
dim SplitData() as Variant, I%, Buffer$
wsk.getdata buffer
SplitData = split(Data, "NAME")
for i = 1 to ubound(splitdata)
debug.print splitdata(i)
next i
This is the easy way to do it i guess, i could be wrong
-
Jul 18th, 2007, 09:41 AM
#4
Re: Winsock data problem
I had that problem too. Like already mentioned, you'll either have to add a specific character symbol at the end of the string being sent so you can then split them at the receving end. The other way I managed to get around this was to use a timer. The timer will cause enough of a delay to make sure that the data is sent one message at a time. The slowest I've set my timer to is half a second and the receving end gets the string one at a time and not bunched up.
Take a look at this thread, we had a small discussion on this:
http://www.vbforums.com/showthread.php?t=477679
Last edited by drivenbywhat; Jul 18th, 2007 at 09:44 AM.
Reason: adding link
[vb5 & starting to move to vb2008] I appreciate the help I get from everyone. Thank you. 
-
Jul 18th, 2007, 11:12 AM
#5
Re: Winsock data problem
The proper/best way is to use a delimiter, like drivenbywhat said.
Avoid using a timer. It slows down your program for no reason, and is not 100% reliable.
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
|