diff options
author | jfrijters <jfrijters> | 2007-07-24 12:47:54 +0400 |
---|---|---|
committer | jfrijters <jfrijters> | 2007-07-24 12:47:54 +0400 |
commit | 43e8dd0f988f4e1e3d07d3be6d50fe04a13ba49d (patch) | |
tree | c5f395160acb31ff6daf311e38ea13de66df5ad6 /openjdk/java/net | |
parent | 942c43a552305395d08b1ad049daa06a0d035a0b (diff) |
Implemented receive timeout.
Diffstat (limited to 'openjdk/java/net')
-rw-r--r-- | openjdk/java/net/PlainDatagramSocketImpl.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/openjdk/java/net/PlainDatagramSocketImpl.java b/openjdk/java/net/PlainDatagramSocketImpl.java index 8363e233..d9937124 100644 --- a/openjdk/java/net/PlainDatagramSocketImpl.java +++ b/openjdk/java/net/PlainDatagramSocketImpl.java @@ -27,6 +27,7 @@ package java.net; import cli.System.Net.IPAddress; import cli.System.Net.IPEndPoint; +import cli.System.Net.Sockets.SelectMode; import cli.System.Net.Sockets.SocketOptionName; import cli.System.Net.Sockets.SocketOptionLevel; import cli.System.Net.Sockets.MulticastOption; @@ -225,6 +226,11 @@ class PlainDatagramSocketImpl extends DatagramSocketImpl { if (false) throw new cli.System.Net.Sockets.SocketException(); if (false) throw new cli.System.ObjectDisposedException(""); + if (timeout > 0 && !netSocket.Poll(Math.min(timeout, Integer.MAX_VALUE / 1000) * 1000, + SelectMode.wrap(SelectMode.SelectRead))) + { + throw new SocketTimeoutException(); + } length = netSocket.ReceiveFrom(p.buf, p.offset, p.bufLength, SocketFlags.wrap(SocketFlags.None), remoteEP); break; } @@ -595,9 +601,6 @@ class PlainDatagramSocketImpl extends DatagramSocketImpl case SocketOptions.IP_MULTICAST_LOOP: netSocket.SetSocketOption(SocketOptionLevel.wrap(SocketOptionLevel.IP), SocketOptionName.wrap(SocketOptionName.MulticastLoopback), ((Boolean)val).booleanValue() ? 1 : 0); break; - case SocketOptions.SO_TIMEOUT: - netSocket.SetSocketOption(SocketOptionLevel.wrap(SocketOptionLevel.Socket), SocketOptionName.wrap(SocketOptionName.ReceiveTimeout), ((Integer)val).intValue()); - break; case SocketOptions.SO_REUSEADDR: PlainSocketImpl.setCommonSocketOption(netSocket, opt, ((Boolean)val).booleanValue(), null); break; @@ -632,8 +635,6 @@ class PlainDatagramSocketImpl extends DatagramSocketImpl throw new SocketException("SocketOptions.IP_MULTICAST_IF(2) not implemented"); case SocketOptions.IP_MULTICAST_LOOP: return CIL.unbox_int(netSocket.GetSocketOption(SocketOptionLevel.wrap(SocketOptionLevel.IP), SocketOptionName.wrap(SocketOptionName.MulticastLoopback))) != 0; - case SocketOptions.SO_TIMEOUT: - return CIL.unbox_int(netSocket.GetSocketOption(SocketOptionLevel.wrap(SocketOptionLevel.Socket), SocketOptionName.wrap(SocketOptionName.ReceiveTimeout))); case SocketOptions.SO_REUSEADDR: return CIL.unbox_int(netSocket.GetSocketOption(SocketOptionLevel.wrap(SocketOptionLevel.Socket), SocketOptionName.wrap(SocketOptionName.ReuseAddress))) != 0; case SocketOptions.SO_SNDBUF: |