1
Network / Socket try connect multiple times
« on: April 27, 2015, 11:22:22 am »
Hello,
I have a project where I need to check in the network if there's already a server. I'm trying to connect a socket and the first time I call the connect method the socket is able to connect but otherwise it can't. Like the socket can only connect if the adress of the server is the first one to be tested.
I have a project where I need to check in the network if there's already a server. I'm trying to connect a socket and the first time I call the connect method the socket is able to connect but otherwise it can't. Like the socket can only connect if the adress of the server is the first one to be tested.
for(int i = first ; i <= last; i++)
{ // net_id -> something like "192.168.140", first and last define the set of adresses
test = net_id;
test.append(".");
test.append(std::to_string(i)); // 192.168.140.1, 192.168.140.2, ...
sf::Socket::Status status = s_test.connect(test,port);
}
{ // net_id -> something like "192.168.140", first and last define the set of adresses
test = net_id;
test.append(".");
test.append(std::to_string(i)); // 192.168.140.1, 192.168.140.2, ...
sf::Socket::Status status = s_test.connect(test,port);
}