diff options
author | Alan Young <consult.awy@gmail.com> | 2016-04-18 18:12:02 (GMT) |
---|---|---|
committer | Alan Young <consult.awy@gmail.com> | 2016-04-20 16:29:51 (GMT) |
commit | 82f43f69b1cdb1d2f6cd11c64a71dc99c8533d5a (patch) | |
tree | c7142eb4b92a901f7faed3516c9c561fde7b713b /src | |
parent | 0b78451839eebdba59d8ac603067f5c7c7d5284c (diff) | |
download | stroke-82f43f69b1cdb1d2f6cd11c64a71dc99c8533d5a.zip stroke-82f43f69b1cdb1d2f6cd11c64a71dc99c8533d5a.tar.bz2 |
Remove use of Java 7 SocketChannel.getRemoteAddress()
Not supported on Android.
Change-Id: I55551ceeed06ab1ff4ce9e5995f809466d0e69bd
Diffstat (limited to 'src')
-rw-r--r-- | src/com/isode/stroke/network/JavaConnection.java | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/src/com/isode/stroke/network/JavaConnection.java b/src/com/isode/stroke/network/JavaConnection.java index 745655f..c7464ba 100644 --- a/src/com/isode/stroke/network/JavaConnection.java +++ b/src/com/isode/stroke/network/JavaConnection.java @@ -7,10 +7,8 @@ package com.isode.stroke.network; import java.io.IOException; import java.net.InetSocketAddress; import java.net.Socket; -import java.net.SocketAddress; import java.nio.ByteBuffer; import java.nio.channels.CancelledKeyException; -import java.nio.channels.ClosedChannelException; import java.nio.channels.ClosedSelectorException; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; @@ -48,6 +46,10 @@ public class JavaConnection extends Connection implements EventOwner { private boolean isWriteNeeded() { return (!writeBuffer_.isEmpty()); } + + public HostAddressPort getRemoteAddress() { + return address_; + } public void run() { try { @@ -518,27 +520,7 @@ public class JavaConnection extends Connection implements EventOwner { @Override public HostAddressPort getRemoteAddress() { - if (socketChannel_ == null) { - return null; - } - SocketAddress remoteAddress; - try { - remoteAddress = socketChannel_.getRemoteAddress(); - } catch (ClosedChannelException e) { - return null; - } catch (IOException e) { - return null; - } - if (!(remoteAddress instanceof InetSocketAddress)) { - // SocketChannel.getRemoteAddress should return a - // InetSocketAddress if it is bound to an IP Socket - // Address so return null if it does not - return null; - } - InetSocketAddress remoteInetAddress = (InetSocketAddress) remoteAddress; - return new HostAddressPort( - new HostAddress(remoteInetAddress.getAddress()), - remoteInetAddress.getPort()); + return worker_.getRemoteAddress(); } @Override |