1
Network / Re: Dropping TCP packets
« on: May 08, 2011, 06:22:29 am »Quote from: "GatorQue"
I think I might know the problem. According to some internet notes, the recv() method will return -1 if you try to read a packet on a NON-BLOCKING socket when there is nothing to be read. This will in turn cause the Socket class to return an Error status to the parent method call which will then abort the reading of the packet right then and there.
So what is the answer you might be asking? It appears that the internet suggests using the "select" call to wait for the socket to be ready before performing the Read operation. I would suggest you try looking at the "Select" tutorial and use the Socket.Wait(timeout) method before performing the Socket.Receive method to get the packet, otherwise your NON-BLOCKING connection might get half-way through reading the packet and run out of bytes and return without giving you the full packet. This might be a bug in the way the SFML TCP Socket class handles NON-BLOCKING Receives, we may want to investigate a little more into the Receive method and determine what if anything can be done to make the Receive(Packet) method more robust when the socket is NON-BLOCKING.
Please let me know if you have any questions and good luck!
Thanks a lot!
I finally solved it, it actually turned out to be a quite silly mistake.
Code: [Select]
sf::SocketTCP sock = (*it).socket;
sock should be a reference, so this solved the problem
Code: [Select]
sf::SocketTCP &sock = (*it).socket;
I was making copies of the socket every frame.
Thank you for your help!