Hmmm...
I'm encountering several problems with the SocketTCP class:
In the moment, I am sending data via loopback. The client uses a blocking socket to send 4 byte of data in a sf::Packet. The server does not use a blocking socket, and he can't do so. (Well, this is REALLY strange, because a blocking socket absolutely blocks even if there is no data left, if the client side does not use sf::Packets (for example, if I try to connect to the socket with netcat). A stable server can not make any assumptions about the thingys connecting to it and about the amount of data sent, so it is not possible to use a blocking socket for me here.)
Now, the problem is, that if I try to receive the 4-byte-packet sent by the client, this sometimes (but rarely) works, but mostly it refuses to work. I am using a sf::Selector to announce me if any sockets are ready to read, but if I try to read from them, the length of the packet is 0.
The whole thing works like the tutorial:
1. Set up a listener, add it to a selector, and wait on this selector.
2. There are some sockets ready to read. If the socket is the listener, accept the connection, and, if successfull, add the new socket to the selector.
3. Else, try to read from the socket. If there is no data (packet length == 0), put the socket into a map together with a Clock to give the socket 1 second for the data of the data to arrive (assuming that the selector will alert me if this happens).
4. If there is data, process it.
... Step 4 is never reached. The length of the packet stays 0, even if the selector thinks there should be data to read.
And no, the tutorial also does not work. The client immediately sees "Press enter to exit...". But the connection is established (the server displays "Client connected ! (127.0.0.1)" and the loopback interface is working.