diff options
author | alanb <none@none> | 2010-06-18 16:16:51 +0100 |
---|---|---|
committer | alanb <none@none> | 2010-06-18 16:16:51 +0100 |
commit | 8a0ea780bec19d8cd7bcf6496037e8922218327f (patch) | |
tree | 8c9daec3ef082bb4dadc42dee7565d2fbb347ee0 /src/share | |
parent | 2aaa08eb8de9cf0ffb7f6d53004ce116293860bb (diff) |
4981129: (dc) DatagramSocket created by DatagramChannel does not provide sender info
Reviewed-by: chegar
Diffstat (limited to 'src/share')
-rw-r--r-- | src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java b/src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java index da54a3d64..a59488814 100644 --- a/src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java +++ b/src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java @@ -171,10 +171,9 @@ public class DatagramSocketAdaptor // Must hold dc.blockingLock() // - private void receive(ByteBuffer bb) throws IOException { + private SocketAddress receive(ByteBuffer bb) throws IOException { if (timeout == 0) { - dc.receive(bb); - return; + return dc.receive(bb); } // Implement timeout with a selector @@ -183,8 +182,9 @@ public class DatagramSocketAdaptor dc.configureBlocking(false); try { int n; - if (dc.receive(bb) != null) - return; + SocketAddress sender; + if ((sender = dc.receive(bb)) != null) + return sender; sel = Util.getTemporarySelector(dc); sk = dc.register(sel, SelectionKey.OP_READ); long to = timeout; @@ -194,8 +194,8 @@ public class DatagramSocketAdaptor long st = System.currentTimeMillis(); int ns = sel.select(to); if (ns > 0 && sk.isReadable()) { - if (dc.receive(bb) != null) - return; + if ((sender = dc.receive(bb)) != null) + return sender; } sel.selectedKeys().remove(sk); to -= System.currentTimeMillis() - st; @@ -222,7 +222,8 @@ public class DatagramSocketAdaptor ByteBuffer bb = ByteBuffer.wrap(p.getData(), p.getOffset(), p.getLength()); - receive(bb); + SocketAddress sender = receive(bb); + p.setSocketAddress(sender); p.setLength(bb.position() - p.getOffset()); } } catch (IOException x) { |