Thread: magic could happen on recvfrom

  1. #16
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    Well first prove that it only runs once, and then have to start looking from there. Don't put a sendto inside of a large loop like that and then claim that it only runs once. KNOW FOR SURE how many times your loop is running. Debug through it if you have to. If it turns out to only run once then start looking elsewhere.
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  2. #17
    Registered User
    Join Date
    Jan 2008
    Posts
    569
    I am 100% at this point it runs once, then it stops when executing fread() as I haven't typed/put anything into stdin

  3. #18
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    Try debugging.
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  4. #19
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    Print out the return value of fread() and see if it is reading more than 256 byte-sized elements.

  5. #20
    Registered User
    Join Date
    Jan 2008
    Posts
    569
    fread() returns 256, I don't know what else to do

  6. #21
    Registered User
    Join Date
    Jan 2008
    Posts
    569
    ok I guess I figured it out now.. yes it does sends it twice after looking at it more carefully... so here's what happened.

    When I send it first time, it is able to send:

    Tom Sawyer is a nice, playful boy, a natural showoff who likes to show his authority over other boys. He is around twelve years old as gathered from hints in Twain's works. Tom is supposed to represent the carefree and wonderful world of boyhood in the ear

    and the second time I tried to send:

    His best friends include Joe Harper and Huckleberry Finn. In The Adventures of Tom Sawyer, Tom's infatuation with Rebecca (alias Becky) Thatcher is apparent. He has a half-brother, Sid, a cousin, Mary, and his aunt is known as Aunt Polly, with all of whom he lives.

    actually this is what it sends:

    ly-mid 1800s.
    His best friends include Joe Harper and Huckleberry Finn. In The Adventures of Tom Sawyer, Tom's infatuation with Rebecca (alias Becky) Thatcher is apparent. He has a half-brother, Sid, a cousin, Mary, and his aunt is known as Aunt Polly, wit

    so now the question is, how does the receiver knows that the 'ly-mid 1800s" goes with the previous one it received?

  7. #22
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    Might have to do with the frame sequences you built.
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  8. #23
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    I'm elaborating, but it looks like if there's enough buffer read (256 bytes), then it sets the size number to 0, which for the server most likely indicates that there is more coming. When the size number is greater than 0, then the server knows it's the last one, and knows that it now has a complete grouping of frames. The sequence number looks like it would be used for the server to order the frames in case they arrive out of order. The flag looks like it is only used to signal the server that there's no more data coming.

    Is this your own code?
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Rubik's Magic?
    By nonoob in forum Game Programming
    Replies: 2
    Last Post: 09-27-2008, 10:17 AM
  2. Windows crashing Magic Square
    By KoshiB in forum C++ Programming
    Replies: 9
    Last Post: 04-19-2006, 09:02 PM
  3. help on magic square
    By katway in forum C Programming
    Replies: 2
    Last Post: 03-07-2005, 06:44 PM
  4. Magic Squares!
    By ZAM777 in forum C++ Programming
    Replies: 1
    Last Post: 04-28-2004, 03:34 PM
  5. magic square whoes
    By caws in forum C Programming
    Replies: 9
    Last Post: 03-30-2003, 10:36 PM