I have been trying to set up a tcp and udp network, and i want to use nonblocking sockets. However i noticed that when i'm using nonblocking sockets the return code for udpSocket.bind() and tcpSocket.connect() doesnt return sf::Socket::Done even if the operation was successful. My workaround was doing this:
tcpSocket.setBlocking(true);
if (tcpSocket.connect(ip,port, sf::seconds(3) ) != sf::TcpSocket::Done){
std::cout<<"Failed to connect TCP"<<std::endl;
tcpSocket.setBlocking(false);
}
Is this intended and is this a good or a bad way to do it?
EDIT: tcpSocket.receive() also returns sf::Socket::Done when it doesn't receive anything in nonblocking mode