Results 1 to 7 of 7

Thread: Problem with Sended data

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    76

    Question Problem with Sended data

    when i try to send alot of data after each athers , like sending data from a loop , like that :

    for i = 0 to 9
    ws1.senddata "Test" & i
    next i

    the recieved data is not separated and looks like that in:

    "Test0Test1Test2Test3"
    "Test4"
    "Test5"
    "Test6Test7"
    "Test8Test9"

    , got it ?!

    like if i did :

    ws1.senddata "Test0Test1Test2Test3"
    ws1.senddata "Test4"
    ..
    ..
    ..


    Help please ,

    thanx

  2. #2
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Problem with Sended data

    That's how it works. A TCP stream is a byte stream and has no more record or message structure than a typical stream textfile. Just as you have to add CrLf to break up a text file into "lines" you need to add something to break up the TCP stream into logical pieces... and you have to assemble the received stream and break out logical pieces at the receiver.

    Unlike something like Line Input for files, the Winsock control doesn't provide any function for assembling data chunks and breaking out "lines."

    People often fool themselves if they have a fast network and slow programs that send intermittently, because then it can seem like the data gets sent in some sort of datagram fashion. As soon as conditions change their programs fall over though.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    76

    Question Re: Problem with Sended data

    I use "|" to separate data

    but , why did two data are sent as if it is 1 data ?


    ws1.SendData "Blues"
    ws1.SendData "Red"

    ==

    ws1.GetData x

    ==

    then i find thet x contains "BluesRed" !!

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    76

    Re: Problem with Sended data

    do you mean to do that :

    ws1.SendData "Blues|"
    ws1.SendData "Red|"

    then use | as seperated if it's sent as "Blues|Red|" ?!

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

    Re: Problem with Sended data

    Quote Originally Posted by dBlues
    do you mean to do that :

    ws1.SendData "Blues|"
    ws1.SendData "Red|"

    then use | as seperated if it's sent as "Blues|Red|" ?!
    Yes, then your program knows where one piece of data begins and the other ends.

    The easiest way to parse that would be to use: Packets() = Split(Data, "|"). Then you have each "packet" in a separate array item.

    Packets(0) = Blues
    Packets(1) = Red

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    76

    Re: Problem with Sended data

    thanx dilettante & DigiRev

    It was great

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Problem with Sended data

    If you consider this resolved, you could help us out by pulling down the Thread Tools menu and clicking the Mark Thread Resolved menu item. That will let everyone know that you have your answer.

    Thank you.

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