1 Reply Latest reply on Mar 8, 2007 5:49 AM by EJP



      I am trying to find whether a server is running on the remote machine on a specified port.

      When the remote server is unreachable, the DatagramSocket.connect(InetAddress, int) always returns without even throwing exception. Even the method DatagramSocket.isConnected also returns true.

      socket.connect(hostname, port);
      if(!this.socket.isConnected()) {
      throw new Exception("Could not connect to Remote server !");

      socket.send gives me an "ICMP Port Unreachable" exception

      Is this how DatagramSocket.connect behaves ?

      How can I find whether any valid server is running a remote machine using DatagramSocket ? Is it possible ?
        • 1. Re: DatagramSocket.connect
          DatagramSocket.connect() just conditions the local IP stack so it only sends & receives datagrams to & from that target/source. It doesn't engage in any network protocol so it can't be used for your purpose.

          If you want to know whether the host and server are there, all you can do is try to send something and get a response.