-
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.
-
I am 100% at this point it runs once, then it stops when executing fread() as I haven't typed/put anything into stdin
-
-
Print out the return value of fread() and see if it is reading more than 256 byte-sized elements.
-
fread() returns 256, I don't know what else to do
-
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?
-
Might have to do with the frame sequences you built.
-
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?