Supposing i know the ip of a pc, is it possible to test if that pc supports remote connection? (windows case)
This appears to work:
http://www.yougetsignal.com/tools/open-ports/
Type in the IP address and then use port "3389" to check for native windows remote desktop.
One way to test if Remote Desktop is available, could be to open a socket to the default RD port (3389). If a connection can be established, assume that RD is available and drop the socket. If connection is refused, RD is most likely not available.
Another approach would be to access information about RD via WMI. This would require the client computer to have sufficient user rights on the (possible) server, though. Inspiration for this approach can be found here:
http://www.vedivi.com/support/blog/71-how-to-enable-remote-desktop-programmatically.html
i figured it out like this
private bool TestPort(string ipString,int port)
{
IPAddress ip = IPAddress.Parse(ipString);
bool test = false;
try
{
System.Net.Sockets.Socket s = new System.Net.Sockets.Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
s.Connect(ip, port);
if (s.Connected == true)
test = true;
s.Close();
}
catch (SocketException ex)
{
test = false;
}
return test;
}
if the function were in c++ would it be faster? how much faster? any suggestions?