/** * If the socket is already connected this returns the remote SocketAddress, otherwise null * * @since 1.4 */ public SocketAddress getRemoteSocketAddress() { if (!isConnected()) return null; return new InetSocketAddress(impl.getInetAddress(), impl.getPort()); }
/** * Checks if the socket is connected * * @since 1.4 */ public boolean isConnected() { return impl.getInetAddress() != null; }
/** * Returns the address of the remote end of the socket. If this socket is not connected, then * <code>null</code> is returned. * * @return The remote address this socket is connected to */ public InetAddress getInetAddress() { if (impl != null) return impl.getInetAddress(); return null; }