SFML community forums

Help => Network => Topic started by: MarcuzPwnz on March 09, 2013, 09:13:32 am

Title: [Solved] receiving multiple packets
Post by: MarcuzPwnz on March 09, 2013, 09:13:32 am
Hey there! I have been playing around with the networking in SFML and I have come across a problem, I have spent a good half hour trying to figure this out, by changing code and reading documentation and still I'm stuck.

So here's a problem. My server receives the first packet sent by the client fine, but as soon as the client sends another packet the server extracts the data from the second packet but when I cout the value of the extracted packet it's the same as the first. So I put in an if statement to check if the packet had been read and it turns out the second packet isn't even being read at all. (From what I understand at least)

Server code: http://pastebin.com/4DJbBMJq
Client code: http://pastebin.com/gdur9qvf

Would anyone be able to point me in the right direction or explain what I am doing wrong? it would be much appreciated. :)

Thank you.
Title: Re: Problem receiving multiple packets
Post by: Laurent on March 09, 2013, 09:28:56 am
On client side, you always append data to the same packet (which grows at every iteration of the loop, keeping the old data at the beginning), instead of creating a new one every time.
Title: Re: Problem receiving multiple packets
Post by: MarcuzPwnz on March 09, 2013, 09:32:51 am
Thank you very much Laurent. :D

I can't believe I didn't notice that. -.-