1 Reply Latest reply: Nov 3, 2008 10:42 PM by 807589 RSS

    socket programming -- check server socket open or not

    807589
      hi...

      im doing a socket program, where the user needs to enter the IP address... will the following code actually test if the socket is open?

      else, wat API must i use to test if the socket is open?

      public static String getIPAddress(){
      //prompts user to enter an ip address, port is fixed
      }
      
      public static void tryConnection(String ipAddress){
          try{
              Socket sock = new Socket(ipAddress, 65500);    
      
             ...
              bool sockIsConnected = sock.isConnected();
          }
          catch(Exception err){
              System.err.println("Error" + err);
          }
      }