Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Billiard26

Pages: [1]
1
Network / SocketTCP::Receive(Packet&) bug
« on: March 02, 2010, 09:04:28 pm »
Quote
Sorry but I don't know what "rumble" means Laughing
Does it have anything to do with force feedback?


Yeah, force feedback. DirectInput force feedback is just so complicated and only for windows. Would be nice to have a simpler interface.

Quote
This part of SFML may be more complete in the future (probably in SFML 2).


Cool. I'd be interested in helping with joystick support for SFML. We could discuss how you want it laid out maybe and I could help jump start improving the joystick functions. I have quite a bit of free time. :lol:

2
Network / SocketTCP::Receive(Packet&) bug
« on: March 02, 2010, 08:02:30 pm »
The fix looks like it would work with non-blocking sockets and seems to work in my project using blocking sockets.

I was experiencing the problem while transmitting a pretty constant stream of packets over the net (didn't seem to happen locally because the packets are received almost instantly and the buffer never has half a packet, I guess).

Thanks for the quick fix. You should add better joystick with basic rumble support to SFML :P ( at least I cant find SFML documentation for anything like joystick count, buttons/axis/hat count, joystick name )

3
Network / SocketTCP::Receive(Packet&) bug
« on: March 02, 2010, 11:19:40 am »
I have been experiencing a bug when receiving packets.
I am using a blocking socket.

A few lines into the function ...
Socket::Status SocketTCP::Receive(Packet& packet)
Code: [Select]

    if (myPendingPacketSize < 0)
    {
        Socket::Status status = Receive(reinterpret_cast<char*>(&packetSize), sizeof(packetSize), received);
        if (status != Socket::Done)
            return status;

        packetSize = ntohl(packetSize);
    }


There is no check for if (sizeof(packetSize) == received)
sizeof(packetSize) is only 4 bytes so almost always all 4 bytes will be received on the first return of Receive.

But not ALWAYS. I have debugged the "received" value in this function to rarely come out 1,2, or 3 which causes packetSize to be read incorrectly, reading into the middle of a packet, and messing up all further received packets on that socket.

Something like the following needs to be done when receiving the header of the packet. ( It's similar to what is being done when receiving the packet's data. It was just assumed 4 bytes is always read first try for the header. )

Code: [Select]

    std::size_t Received   = 0;
while (Received < sizeof(PacketSize))
{
std::size_t r;
Socket::Status Status = Receive(reinterpret_cast<char*>(&PacketSize)+Received, sizeof(PacketSize)-Received, r);
if (Status != Socket::Done)
return Status;
Received += r;
}

        PacketSize = ntohl(PacketSize);


When using this modification all of my packets are received correctly 100% of the time. It could be dependent on the OS for who would experience the problem and who wouldn't.

Pages: [1]
anything