Hi there,
Im trying to connect to localhost with the Listening part running in a seperate thread... but it wont connect... and i dont know why :/
I tried many differend setting for IP, like "127.0.0.1" or "192.168.1.34" (Thats my local IP) but it wont connect..
The Idea behind is that i wanted to create a small game for multiple users, and one of them is the Host and he listens so users can connect...
My thought was that the connect is "too fast" so i put it into a loop so he connects over and over when he fails, but he never get the connection even then :/
lthread = new sf::Thread(&Host::Listen, this);
lthread->launch();
void Host::Listen()
{
sf::TcpListener Listener;
Listener.listen(1234);
quit = false;
while (!quit)
{
sf::TcpSocket *client = new sf::TcpSocket;
Listener.accept(*client);
}
}
if ((clientSocket.connect("127.0.0.1", 1234) == sf::Socket::Done))
{
connected = true;
}