Results 1 to 5 of 5

Thread: [RESOLVED] Winsock data problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    5

    Resolved [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

  2. #2
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    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!

  3. #3
    Addicted Member
    Join Date
    Apr 2003
    Posts
    148

    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

  4. #4
    Fanatic Member drivenbywhat's Avatar
    Join Date
    Jan 2007
    Location
    VA - USA
    Posts
    866

    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.

  5. #5
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    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
  •  



Click Here to Expand Forum to Full Width