I am trying to build some program that detects if a server of some game is on or off, I have the IP and the port of the server.
What do I have to do to detect whether the server is on or off? Sockets? Ping class?
It would be nice if you guys could give me a code sample or something.
Thank you very much!
See Socket.Connect
By pinging a server you can get an indication whether the server is ‘on’ or ‘off’; it doesn’t give an indication whether the service you’re trying to connect to is running or not.
if the first option is what you’re looking for (a general idea whether the server is on&connected to the internet), pinging will suffice for this task.
As per the efficiency – pinging is more efficient (well, in large scale terms) as only 2 packets are being exchanged between the server and the client, rather than a full connection establishment which is about 3 packets –
See TCP 3-Way handshake