2014-05-22 112 views

回答

1
TcpClient tcpClient = new TcpClient(); 
     try 
      { 
       tcpClient.Connect("152.26.53.39", 2775); 
       Console.WriteLine("Port 2775 Open"); 
      } 
     catch (Exception){ 

       Console.WriteLine("Port 2775 Closed"); 
     } 
0

您可以如下使用Ping class

string nameOrAddress="152.26.53.39 2775"; 
public static bool PingHost(string nameOrAddress) 
{ 
    bool pingable = false; 
    Ping pinger = new Ping(); 

    try 
    { 
     PingReply reply = pinger.Send(nameOrAddress); 

     pingable = reply.Status == IPStatus.Success; 
    } 
    catch (PingException) 
    { 
     // Discard PingExceptions and return false; 
    } 

    return pingable; 
} 
相關問題