summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorBrian P. Hinz <bphinz@users.sf.net>2014-11-13 21:30:27 -0500
committerBrian P. Hinz <bphinz@users.sf.net>2014-11-13 21:30:27 -0500
commitd5147453f7337792ac59a20a3db25abf9c4adf19 (patch)
tree0cd9ba1de813e5f565ee677f3d4aec0e9c71dd5d /java
parent12c358230645ca37e438941f61ff00acfe251c54 (diff)
downloadtigervnc-d5147453f7337792ac59a20a3db25abf9c4adf19.tar.gz
tigervnc-d5147453f7337792ac59a20a3db25abf9c4adf19.zip
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.
Diffstat (limited to 'java')
-rw-r--r--java/com/tigervnc/network/TcpListener.java6
-rw-r--r--java/com/tigervnc/network/TcpSocket.java5
2 files changed, 5 insertions, 6 deletions
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. */