eocron06 eocron06 - 1 month ago 11
C# Question

Is there a way to check if RDP connection possible?

I have my home server, and want to create manager what will wake up my computer and check if RDP connect now possible.

I accomplished WOL behavior, but now there is problem with checking if computer OS turned on and ready for RDP connections.

Is it possible to 'ping' RDP?

Evk Evk
Answer

You can just check if you can connect to RDP port (by default 3389):

static bool IsRdpAvailable(string host) {
    try {
        using (new TcpClient(host, 3389)) {
            return true;
        }
    }
    catch {
        return false;
    }
} 

Usage:

bool available = IsRdpAvailable("your_server_ip_or_name");