You are not logged in.
Hi guys!
When I try to (synch) connect to a TCP port on an IP that's NOT online, the program stops running at the .connect(); point. How can I check on beforehand if the host is online?
I'm using TCP sockets in boost c++.
Should I ping?
Ruben
Offline
You can't check beforehand whether a host is available or not, especially not with pings. The host might still become unavailable between the check and the actual connection attempt, and it might well respond to pings, but still not provide the specific port you are trying to connect to. You can also connect to hosts, which aren't pingable.
If a host is not available, "connect()" will wait until a time-out occurs. I don't know the boost API well enough to tell you whether you can configure this time-out, but if not, you can still use the asynchronous methods (e.g. "async_connect()"). After all, that is what boost::asio is actually made for.
Offline