What's wrong with this? :
while (!done)
{
std::cout << "Creating connection" << std::endl;
sf::TcpSocket socket;
sf::Socket::Status status = socket.connect("192.168.0.5", 53000);
if (status != sf::Socket::Done)
{
std::cout << "Client Error" << std::endl;
}
std::cout << "Created" << std::endl;
char data[100] = { 'H', 'e', 'l', 'l', 'o', '\0' };
system("pause");
if (socket.send(data, 100) != sf::Socket::Done)
{
std::cout << "Client Error : Couldn't send data" << std::endl;
}
}
Basically it sends the data the first time, then fail the second, and work the third, and fail the fourth and... you get what I mean...
How do I fix it?
(Ignore the "system("pause")" it's just to test and it's faster than typing something everytime.