Search code examples
c#socketstelnettcpclientsmpp

How to Check Server is accepting connections


I just want to check if smpp server is accepting connections. As we can check it using command prompt with the following command: telnet 152.26.53.39 2775 I simply want to code this command in C#


Solution

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