/** * 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()); }
/** * Returns the port number of the remote end of the socket connection. If this socket is not * connected, then -1 is returned. * * @return The remote port this socket is connected to */ public int getPort() { if (impl != null) return impl.getPort(); return -1; }