From: Brian P. Hinz Date: Fri, 14 Nov 2014 02:30:27 +0000 (-0500) Subject: Fix getSockPort methods in java TcpSocket X-Git-Tag: v1.3.90~8^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d5147453f7337792ac59a20a3db25abf9c4adf19;p=tigervnc.git Fix getSockPort methods in java TcpSocket Although not actually used anywhere, the getSockPort method was actually returning the the remote socket's port number. Also simplified some of the other socket methods. --- diff --git a/java/com/tigervnc/network/TcpListener.java b/java/com/tigervnc/network/TcpListener.java index 6170a602..45ee8a4d 100644 --- a/java/com/tigervnc/network/TcpListener.java +++ b/java/com/tigervnc/network/TcpListener.java @@ -144,9 +144,9 @@ public class TcpListener extends SocketListener { return s; } - //public int getMyPort() { - // return TcpSocket.getSockPort(); - //} + public int getMyPort() { + return ((SocketDescriptor)getFd()).socket().getLocalPort(); + } private boolean closeFd; private ServerSocketChannel channel; diff --git a/java/com/tigervnc/network/TcpSocket.java b/java/com/tigervnc/network/TcpSocket.java index 051a9d82..43787e4d 100644 --- a/java/com/tigervnc/network/TcpSocket.java +++ b/java/com/tigervnc/network/TcpSocket.java @@ -113,8 +113,7 @@ public class TcpSocket extends Socket { } public int getMyPort() { - SocketAddress address = ((SocketDescriptor)getFd()).socket().getLocalSocketAddress(); - return ((InetSocketAddress)address).getPort(); + return getSockPort(); } public String getPeerAddress() { @@ -184,7 +183,7 @@ public class TcpSocket extends Socket { } public int getSockPort() { - return ((InetSocketAddress)((SocketDescriptor)getFd()).socket().getRemoteSocketAddress()).getPort(); + return ((SocketDescriptor)getFd()).socket().getLocalPort(); } /* Tunnelling support. */