jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
Print this page
rev 5725 : Merge
@@ -417,24 +417,24 @@
if (src == null)
throw new NullPointerException();
synchronized (writeLock) {
ensureOpen();
- InetSocketAddress isa = (InetSocketAddress)target;
+ InetSocketAddress isa = Net.checkAddress(target);
InetAddress ia = isa.getAddress();
if (ia == null)
throw new IOException("Target address not resolved");
synchronized (stateLock) {
if (!isConnected()) {
if (target == null)
throw new NullPointerException();
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
if (ia.isMulticastAddress()) {
- sm.checkMulticast(isa.getAddress());
+ sm.checkMulticast(ia);
} else {
- sm.checkConnect(isa.getAddress().getHostAddress(),
+ sm.checkConnect(ia.getHostAddress(),
isa.getPort());
}
}
} else { // Connected case; Check address then write
if (!target.equals(remoteAddress)) {
@@ -450,11 +450,11 @@
begin();
if (!isOpen())
return 0;
writerThread = NativeThread.current();
do {
- n = send(fd, src, target);
+ n = send(fd, src, isa);
} while ((n == IOStatus.INTERRUPTED) && isOpen());
synchronized (stateLock) {
if (isOpen() && (localAddress == null)) {
localAddress = Net.localAddress(fd);
@@ -467,11 +467,11 @@
assert IOStatus.check(n);
}
}
}
- private int send(FileDescriptor fd, ByteBuffer src, SocketAddress target)
+ private int send(FileDescriptor fd, ByteBuffer src, InetSocketAddress target)
throws IOException
{
if (src instanceof DirectBuffer)
return sendFromNativeBuffer(fd, src, target);
@@ -498,11 +498,11 @@
Util.releaseTemporaryDirectBuffer(bb);
}
}
private int sendFromNativeBuffer(FileDescriptor fd, ByteBuffer bb,
- SocketAddress target)
+ InetSocketAddress target)
throws IOException
{
int pos = bb.position();
int lim = bb.limit();
assert (pos <= lim);
@@ -510,11 +510,11 @@
boolean preferIPv6 = (family != StandardProtocolFamily.INET);
int written;
try {
written = send0(preferIPv6, fd, ((DirectBuffer)bb).address() + pos,
- rem, target);
+ rem, target.getAddress(), target.getPort());
} catch (PortUnreachableException pue) {
if (isConnected())
throw pue;
written = rem;
}
@@ -1090,12 +1090,12 @@
private native int receive0(FileDescriptor fd, long address, int len,
boolean connected)
throws IOException;
- private native int send0(boolean preferIPv6, FileDescriptor fd, long address, int len,
- SocketAddress sa)
+ private native int send0(boolean preferIPv6, FileDescriptor fd, long address,
+ int len, InetAddress addr, int port)
throws IOException;
static {
Util.load();
initIDs();