mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 11:34:38 +02:00
8202091: Rename DualStackPlainSocketImpl to PlainSocketImpl [win]
Reviewed-by: clanger, chegar
This commit is contained in:
parent
cac6379cc4
commit
3649ace8a0
3 changed files with 332 additions and 617 deletions
|
@ -1,356 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package java.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.FileDescriptor;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import jdk.internal.misc.JavaIOFileDescriptorAccess;
|
||||
|
||||
/**
|
||||
* This class defines the plain SocketImpl.
|
||||
* When java.net.preferIPv4Stack system property is set to true, it uses
|
||||
* IPv4-only socket.
|
||||
* When java.net.preferIPv4Stack is set to false, it handles both IPv4
|
||||
* and IPv6 through a single file descriptor.
|
||||
*
|
||||
* @author Chris Hegarty
|
||||
*/
|
||||
|
||||
class DualStackPlainSocketImpl extends AbstractPlainSocketImpl {
|
||||
|
||||
private static final JavaIOFileDescriptorAccess fdAccess =
|
||||
SharedSecrets.getJavaIOFileDescriptorAccess();
|
||||
|
||||
private static final boolean preferIPv4Stack =
|
||||
Boolean.parseBoolean(AccessController.doPrivileged(
|
||||
new GetPropertyAction("java.net.preferIPv4Stack", "false")));
|
||||
|
||||
/**
|
||||
* Empty value of sun.net.useExclusiveBind is treated as 'true'.
|
||||
*/
|
||||
private static final boolean useExclusiveBind;
|
||||
|
||||
static {
|
||||
String exclBindProp = AccessController.doPrivileged(
|
||||
new GetPropertyAction("sun.net.useExclusiveBind", ""));
|
||||
useExclusiveBind = exclBindProp.isEmpty()
|
||||
|| Boolean.parseBoolean(exclBindProp);
|
||||
}
|
||||
|
||||
// emulates SO_REUSEADDR when useExclusiveBind is true
|
||||
private boolean isReuseAddress;
|
||||
|
||||
public DualStackPlainSocketImpl() {
|
||||
}
|
||||
|
||||
public DualStackPlainSocketImpl(FileDescriptor fd) {
|
||||
this.fd = fd;
|
||||
}
|
||||
|
||||
@Override
|
||||
void socketCreate(boolean stream) throws IOException {
|
||||
if (fd == null)
|
||||
throw new SocketException("Socket closed");
|
||||
|
||||
int newfd = socket0(stream);
|
||||
|
||||
fdAccess.set(fd, newfd);
|
||||
}
|
||||
|
||||
@Override
|
||||
void socketConnect(InetAddress address, int port, int timeout)
|
||||
throws IOException {
|
||||
int nativefd = checkAndReturnNativeFD();
|
||||
|
||||
if (address == null)
|
||||
throw new NullPointerException("inet address argument is null.");
|
||||
|
||||
if (preferIPv4Stack && !(address instanceof Inet4Address))
|
||||
throw new SocketException("Protocol family not supported");
|
||||
|
||||
int connectResult;
|
||||
if (timeout <= 0) {
|
||||
connectResult = connect0(nativefd, address, port);
|
||||
} else {
|
||||
configureBlocking(nativefd, false);
|
||||
try {
|
||||
connectResult = connect0(nativefd, address, port);
|
||||
if (connectResult == WOULDBLOCK) {
|
||||
waitForConnect(nativefd, timeout);
|
||||
}
|
||||
} finally {
|
||||
configureBlocking(nativefd, true);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* We need to set the local port field. If bind was called
|
||||
* previous to the connect (by the client) then localport field
|
||||
* will already be set.
|
||||
*/
|
||||
if (localport == 0)
|
||||
localport = localPort0(nativefd);
|
||||
}
|
||||
|
||||
@Override
|
||||
void socketBind(InetAddress address, int port) throws IOException {
|
||||
int nativefd = checkAndReturnNativeFD();
|
||||
|
||||
if (address == null)
|
||||
throw new NullPointerException("inet address argument is null.");
|
||||
|
||||
if (preferIPv4Stack && !(address instanceof Inet4Address))
|
||||
throw new SocketException("Protocol family not supported");
|
||||
|
||||
bind0(nativefd, address, port, useExclusiveBind);
|
||||
if (port == 0) {
|
||||
localport = localPort0(nativefd);
|
||||
} else {
|
||||
localport = port;
|
||||
}
|
||||
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
@Override
|
||||
void socketListen(int backlog) throws IOException {
|
||||
int nativefd = checkAndReturnNativeFD();
|
||||
|
||||
listen0(nativefd, backlog);
|
||||
}
|
||||
|
||||
@Override
|
||||
void socketAccept(SocketImpl s) throws IOException {
|
||||
int nativefd = checkAndReturnNativeFD();
|
||||
|
||||
if (s == null)
|
||||
throw new NullPointerException("socket is null");
|
||||
|
||||
int newfd = -1;
|
||||
InetSocketAddress[] isaa = new InetSocketAddress[1];
|
||||
if (timeout <= 0) {
|
||||
newfd = accept0(nativefd, isaa);
|
||||
} else {
|
||||
configureBlocking(nativefd, false);
|
||||
try {
|
||||
waitForNewConnection(nativefd, timeout);
|
||||
newfd = accept0(nativefd, isaa);
|
||||
if (newfd != -1) {
|
||||
configureBlocking(newfd, true);
|
||||
}
|
||||
} finally {
|
||||
configureBlocking(nativefd, true);
|
||||
}
|
||||
}
|
||||
/* Update (SocketImpl)s' fd */
|
||||
fdAccess.set(s.fd, newfd);
|
||||
/* Update socketImpls remote port, address and localport */
|
||||
InetSocketAddress isa = isaa[0];
|
||||
s.port = isa.getPort();
|
||||
s.address = isa.getAddress();
|
||||
s.localport = localport;
|
||||
if (preferIPv4Stack && !(s.address instanceof Inet4Address))
|
||||
throw new SocketException("Protocol family not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
int socketAvailable() throws IOException {
|
||||
int nativefd = checkAndReturnNativeFD();
|
||||
return available0(nativefd);
|
||||
}
|
||||
|
||||
@Override
|
||||
void socketClose0(boolean useDeferredClose/*unused*/) throws IOException {
|
||||
if (fd == null)
|
||||
throw new SocketException("Socket closed");
|
||||
|
||||
if (!fd.valid())
|
||||
return;
|
||||
|
||||
final int nativefd = fdAccess.get(fd);
|
||||
fdAccess.set(fd, -1);
|
||||
close0(nativefd);
|
||||
}
|
||||
|
||||
@Override
|
||||
void socketShutdown(int howto) throws IOException {
|
||||
int nativefd = checkAndReturnNativeFD();
|
||||
shutdown0(nativefd, howto);
|
||||
}
|
||||
|
||||
// Intentional fallthrough after SO_REUSEADDR
|
||||
@SuppressWarnings("fallthrough")
|
||||
@Override
|
||||
void socketSetOption(int opt, boolean on, Object value)
|
||||
throws SocketException {
|
||||
|
||||
// SO_REUSEPORT is not supported on Windows.
|
||||
if (opt == SO_REUSEPORT) {
|
||||
throw new UnsupportedOperationException("unsupported option");
|
||||
}
|
||||
|
||||
int nativefd = checkAndReturnNativeFD();
|
||||
|
||||
if (opt == SO_TIMEOUT) {
|
||||
if (preferIPv4Stack) {
|
||||
// Don't enable the socket option on ServerSocket as it's
|
||||
// meaningless (we don't receive on a ServerSocket).
|
||||
if (serverSocket == null) {
|
||||
setSoTimeout0(nativefd, ((Integer)value).intValue());
|
||||
}
|
||||
} // else timeout is implemented through select.
|
||||
return;
|
||||
}
|
||||
|
||||
int optionValue = 0;
|
||||
|
||||
switch(opt) {
|
||||
case SO_REUSEADDR:
|
||||
if (useExclusiveBind) {
|
||||
// SO_REUSEADDR emulated when using exclusive bind
|
||||
isReuseAddress = on;
|
||||
return;
|
||||
}
|
||||
// intentional fallthrough
|
||||
case TCP_NODELAY:
|
||||
case SO_OOBINLINE:
|
||||
case SO_KEEPALIVE:
|
||||
optionValue = on ? 1 : 0;
|
||||
break;
|
||||
case SO_SNDBUF:
|
||||
case SO_RCVBUF:
|
||||
case IP_TOS:
|
||||
optionValue = ((Integer)value).intValue();
|
||||
break;
|
||||
case SO_LINGER:
|
||||
if (on) {
|
||||
optionValue = ((Integer)value).intValue();
|
||||
} else {
|
||||
optionValue = -1;
|
||||
}
|
||||
break;
|
||||
default :/* shouldn't get here */
|
||||
throw new SocketException("Option not supported");
|
||||
}
|
||||
|
||||
setIntOption(nativefd, opt, optionValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
int socketGetOption(int opt, Object iaContainerObj)
|
||||
throws SocketException {
|
||||
|
||||
// SO_REUSEPORT is not supported on Windows.
|
||||
if (opt == SO_REUSEPORT) {
|
||||
throw new UnsupportedOperationException("unsupported option");
|
||||
}
|
||||
|
||||
int nativefd = checkAndReturnNativeFD();
|
||||
|
||||
// SO_BINDADDR is not a socket option.
|
||||
if (opt == SO_BINDADDR) {
|
||||
localAddress(nativefd, (InetAddressContainer)iaContainerObj);
|
||||
return 0; // return value doesn't matter.
|
||||
}
|
||||
|
||||
// SO_REUSEADDR emulated when using exclusive bind
|
||||
if (opt == SO_REUSEADDR && useExclusiveBind)
|
||||
return isReuseAddress ? 1 : -1;
|
||||
|
||||
int value = getIntOption(nativefd, opt);
|
||||
|
||||
switch (opt) {
|
||||
case TCP_NODELAY:
|
||||
case SO_OOBINLINE:
|
||||
case SO_KEEPALIVE:
|
||||
case SO_REUSEADDR:
|
||||
return (value == 0) ? -1 : 1;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
void socketSendUrgentData(int data) throws IOException {
|
||||
int nativefd = checkAndReturnNativeFD();
|
||||
sendOOB(nativefd, data);
|
||||
}
|
||||
|
||||
private int checkAndReturnNativeFD() throws SocketException {
|
||||
if (fd == null || !fd.valid())
|
||||
throw new SocketException("Socket closed");
|
||||
|
||||
return fdAccess.get(fd);
|
||||
}
|
||||
|
||||
static final int WOULDBLOCK = -2; // Nothing available (non-blocking)
|
||||
|
||||
static {
|
||||
initIDs();
|
||||
}
|
||||
|
||||
/* Native methods */
|
||||
|
||||
static native void initIDs();
|
||||
|
||||
static native int socket0(boolean stream) throws IOException;
|
||||
|
||||
static native void bind0(int fd, InetAddress localAddress, int localport,
|
||||
boolean exclBind)
|
||||
throws IOException;
|
||||
|
||||
static native int connect0(int fd, InetAddress remote, int remotePort)
|
||||
throws IOException;
|
||||
|
||||
static native void waitForConnect(int fd, int timeout) throws IOException;
|
||||
|
||||
static native int localPort0(int fd) throws IOException;
|
||||
|
||||
static native void localAddress(int fd, InetAddressContainer in) throws SocketException;
|
||||
|
||||
static native void listen0(int fd, int backlog) throws IOException;
|
||||
|
||||
static native int accept0(int fd, InetSocketAddress[] isaa) throws IOException;
|
||||
|
||||
static native void waitForNewConnection(int fd, int timeout) throws IOException;
|
||||
|
||||
static native int available0(int fd) throws IOException;
|
||||
|
||||
static native void close0(int fd) throws IOException;
|
||||
|
||||
static native void shutdown0(int fd, int howto) throws IOException;
|
||||
|
||||
static native void setIntOption(int fd, int cmd, int optionValue) throws SocketException;
|
||||
|
||||
static native void setSoTimeout0(int fd, int timeout) throws SocketException;
|
||||
|
||||
static native int getIntOption(int fd, int cmd) throws SocketException;
|
||||
|
||||
static native void sendOOB(int fd, int data) throws IOException;
|
||||
|
||||
static native void configureBlocking(int fd, boolean blocking) throws IOException;
|
||||
}
|
|
@ -24,261 +24,335 @@
|
|||
*/
|
||||
package java.net;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.FileDescriptor;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import jdk.internal.misc.JavaIOFileDescriptorAccess;
|
||||
|
||||
/*
|
||||
* This class PlainSocketImpl simply delegates to the appropriate real
|
||||
* SocketImpl. We do this because PlainSocketImpl is already extended
|
||||
* by SocksSocketImpl.
|
||||
* <p>
|
||||
* There is one possibility for the real SocketImpl: DualStackPlainSocketImpl.
|
||||
/**
|
||||
* On Windows system we simply delegate to native methods.
|
||||
*
|
||||
* @author Chris Hegarty
|
||||
*/
|
||||
|
||||
class PlainSocketImpl extends AbstractPlainSocketImpl {
|
||||
private AbstractPlainSocketImpl impl;
|
||||
|
||||
private static final JavaIOFileDescriptorAccess fdAccess =
|
||||
SharedSecrets.getJavaIOFileDescriptorAccess();
|
||||
|
||||
private static final boolean preferIPv4Stack =
|
||||
Boolean.parseBoolean(AccessController.doPrivileged(
|
||||
new GetPropertyAction("java.net.preferIPv4Stack", "false")));
|
||||
|
||||
/**
|
||||
* Empty value of sun.net.useExclusiveBind is treated as 'true'.
|
||||
*/
|
||||
private static final boolean useExclusiveBind;
|
||||
|
||||
static {
|
||||
String exclBindProp = AccessController.doPrivileged(
|
||||
new GetPropertyAction("sun.net.useExclusiveBind", ""));
|
||||
useExclusiveBind = exclBindProp.isEmpty()
|
||||
|| Boolean.parseBoolean(exclBindProp);
|
||||
}
|
||||
|
||||
// emulates SO_REUSEADDR when useExclusiveBind is true
|
||||
private boolean isReuseAddress;
|
||||
|
||||
/**
|
||||
* Constructs an empty instance.
|
||||
*/
|
||||
PlainSocketImpl() {
|
||||
impl = new DualStackPlainSocketImpl();
|
||||
public PlainSocketImpl() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance with the given file descriptor.
|
||||
*/
|
||||
PlainSocketImpl(FileDescriptor fd) {
|
||||
impl = new DualStackPlainSocketImpl(fd);
|
||||
public PlainSocketImpl(FileDescriptor fd) {
|
||||
this.fd = fd;
|
||||
}
|
||||
|
||||
// Override methods in SocketImpl that access impl's fields.
|
||||
|
||||
protected FileDescriptor getFileDescriptor() {
|
||||
return impl.getFileDescriptor();
|
||||
}
|
||||
|
||||
protected InetAddress getInetAddress() {
|
||||
return impl.getInetAddress();
|
||||
}
|
||||
|
||||
protected int getPort() {
|
||||
return impl.getPort();
|
||||
}
|
||||
|
||||
protected int getLocalPort() {
|
||||
return impl.getLocalPort();
|
||||
}
|
||||
|
||||
void setSocket(Socket soc) {
|
||||
impl.setSocket(soc);
|
||||
}
|
||||
|
||||
Socket getSocket() {
|
||||
return impl.getSocket();
|
||||
}
|
||||
|
||||
void setServerSocket(ServerSocket soc) {
|
||||
impl.setServerSocket(soc);
|
||||
}
|
||||
|
||||
ServerSocket getServerSocket() {
|
||||
return impl.getServerSocket();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return impl.toString();
|
||||
}
|
||||
|
||||
// Override methods in AbstractPlainSocketImpl that access impl's fields.
|
||||
|
||||
protected synchronized void create(boolean stream) throws IOException {
|
||||
impl.create(stream);
|
||||
|
||||
// set fd to delegate's fd to be compatible with older releases
|
||||
this.fd = impl.fd;
|
||||
}
|
||||
|
||||
protected void connect(String host, int port)
|
||||
throws UnknownHostException, IOException
|
||||
{
|
||||
impl.connect(host, port);
|
||||
}
|
||||
|
||||
protected void connect(InetAddress address, int port) throws IOException {
|
||||
impl.connect(address, port);
|
||||
}
|
||||
|
||||
protected void connect(SocketAddress address, int timeout) throws IOException {
|
||||
impl.connect(address, timeout);
|
||||
}
|
||||
|
||||
public void setOption(int opt, Object val) throws SocketException {
|
||||
impl.setOption(opt, val);
|
||||
}
|
||||
|
||||
public Object getOption(int opt) throws SocketException {
|
||||
return impl.getOption(opt);
|
||||
}
|
||||
|
||||
synchronized void doConnect(InetAddress address, int port, int timeout) throws IOException {
|
||||
impl.doConnect(address, port, timeout);
|
||||
}
|
||||
|
||||
protected synchronized void bind(InetAddress address, int lport)
|
||||
throws IOException
|
||||
{
|
||||
impl.bind(address, lport);
|
||||
}
|
||||
|
||||
protected synchronized void accept(SocketImpl s) throws IOException {
|
||||
if (s instanceof PlainSocketImpl) {
|
||||
// pass in the real impl not the wrapper.
|
||||
SocketImpl delegate = ((PlainSocketImpl)s).impl;
|
||||
delegate.address = new InetAddress();
|
||||
delegate.fd = new FileDescriptor();
|
||||
impl.accept(delegate);
|
||||
// set fd to delegate's fd to be compatible with older releases
|
||||
s.fd = delegate.fd;
|
||||
} else {
|
||||
impl.accept(s);
|
||||
}
|
||||
}
|
||||
|
||||
void setFileDescriptor(FileDescriptor fd) {
|
||||
impl.setFileDescriptor(fd);
|
||||
}
|
||||
|
||||
void setAddress(InetAddress address) {
|
||||
impl.setAddress(address);
|
||||
}
|
||||
|
||||
void setPort(int port) {
|
||||
impl.setPort(port);
|
||||
}
|
||||
|
||||
void setLocalPort(int localPort) {
|
||||
impl.setLocalPort(localPort);
|
||||
}
|
||||
|
||||
protected synchronized InputStream getInputStream() throws IOException {
|
||||
return impl.getInputStream();
|
||||
}
|
||||
|
||||
void setInputStream(SocketInputStream in) {
|
||||
impl.setInputStream(in);
|
||||
}
|
||||
|
||||
protected synchronized OutputStream getOutputStream() throws IOException {
|
||||
return impl.getOutputStream();
|
||||
}
|
||||
|
||||
protected void close() throws IOException {
|
||||
try {
|
||||
impl.close();
|
||||
} finally {
|
||||
// set fd to delegate's fd to be compatible with older releases
|
||||
this.fd = null;
|
||||
}
|
||||
}
|
||||
|
||||
void reset() throws IOException {
|
||||
try {
|
||||
impl.reset();
|
||||
} finally {
|
||||
// set fd to delegate's fd to be compatible with older releases
|
||||
this.fd = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void shutdownInput() throws IOException {
|
||||
impl.shutdownInput();
|
||||
}
|
||||
|
||||
protected void shutdownOutput() throws IOException {
|
||||
impl.shutdownOutput();
|
||||
}
|
||||
|
||||
protected void sendUrgentData(int data) throws IOException {
|
||||
impl.sendUrgentData(data);
|
||||
}
|
||||
|
||||
FileDescriptor acquireFD() {
|
||||
return impl.acquireFD();
|
||||
}
|
||||
|
||||
void releaseFD() {
|
||||
impl.releaseFD();
|
||||
}
|
||||
|
||||
boolean isConnectionReset() {
|
||||
return impl.isConnectionReset();
|
||||
}
|
||||
|
||||
void setConnectionReset() {
|
||||
impl.setConnectionReset();
|
||||
}
|
||||
|
||||
public boolean isClosedOrPending() {
|
||||
return impl.isClosedOrPending();
|
||||
}
|
||||
|
||||
public int getTimeout() {
|
||||
return impl.getTimeout();
|
||||
}
|
||||
|
||||
// Override methods in AbstractPlainSocketImpl that need to be implemented.
|
||||
|
||||
@Override
|
||||
void socketCreate(boolean stream) throws IOException {
|
||||
impl.socketCreate(stream);
|
||||
if (fd == null)
|
||||
throw new SocketException("Socket closed");
|
||||
|
||||
int newfd = socket0(stream);
|
||||
|
||||
fdAccess.set(fd, newfd);
|
||||
}
|
||||
|
||||
@Override
|
||||
void socketConnect(InetAddress address, int port, int timeout)
|
||||
throws IOException {
|
||||
impl.socketConnect(address, port, timeout);
|
||||
int nativefd = checkAndReturnNativeFD();
|
||||
|
||||
if (address == null)
|
||||
throw new NullPointerException("inet address argument is null.");
|
||||
|
||||
if (preferIPv4Stack && !(address instanceof Inet4Address))
|
||||
throw new SocketException("Protocol family not supported");
|
||||
|
||||
int connectResult;
|
||||
if (timeout <= 0) {
|
||||
connectResult = connect0(nativefd, address, port);
|
||||
} else {
|
||||
configureBlocking(nativefd, false);
|
||||
try {
|
||||
connectResult = connect0(nativefd, address, port);
|
||||
if (connectResult == WOULDBLOCK) {
|
||||
waitForConnect(nativefd, timeout);
|
||||
}
|
||||
} finally {
|
||||
configureBlocking(nativefd, true);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* We need to set the local port field. If bind was called
|
||||
* previous to the connect (by the client) then localport field
|
||||
* will already be set.
|
||||
*/
|
||||
if (localport == 0)
|
||||
localport = localPort0(nativefd);
|
||||
}
|
||||
|
||||
void socketBind(InetAddress address, int port)
|
||||
throws IOException {
|
||||
impl.socketBind(address, port);
|
||||
@Override
|
||||
void socketBind(InetAddress address, int port) throws IOException {
|
||||
int nativefd = checkAndReturnNativeFD();
|
||||
|
||||
if (address == null)
|
||||
throw new NullPointerException("inet address argument is null.");
|
||||
|
||||
if (preferIPv4Stack && !(address instanceof Inet4Address))
|
||||
throw new SocketException("Protocol family not supported");
|
||||
|
||||
bind0(nativefd, address, port, useExclusiveBind);
|
||||
if (port == 0) {
|
||||
localport = localPort0(nativefd);
|
||||
} else {
|
||||
localport = port;
|
||||
}
|
||||
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
void socketListen(int count) throws IOException {
|
||||
impl.socketListen(count);
|
||||
@Override
|
||||
void socketListen(int backlog) throws IOException {
|
||||
int nativefd = checkAndReturnNativeFD();
|
||||
|
||||
listen0(nativefd, backlog);
|
||||
}
|
||||
|
||||
@Override
|
||||
void socketAccept(SocketImpl s) throws IOException {
|
||||
impl.socketAccept(s);
|
||||
int nativefd = checkAndReturnNativeFD();
|
||||
|
||||
if (s == null)
|
||||
throw new NullPointerException("socket is null");
|
||||
|
||||
int newfd = -1;
|
||||
InetSocketAddress[] isaa = new InetSocketAddress[1];
|
||||
if (timeout <= 0) {
|
||||
newfd = accept0(nativefd, isaa);
|
||||
} else {
|
||||
configureBlocking(nativefd, false);
|
||||
try {
|
||||
waitForNewConnection(nativefd, timeout);
|
||||
newfd = accept0(nativefd, isaa);
|
||||
if (newfd != -1) {
|
||||
configureBlocking(newfd, true);
|
||||
}
|
||||
} finally {
|
||||
configureBlocking(nativefd, true);
|
||||
}
|
||||
}
|
||||
/* Update (SocketImpl)s' fd */
|
||||
fdAccess.set(s.fd, newfd);
|
||||
/* Update socketImpls remote port, address and localport */
|
||||
InetSocketAddress isa = isaa[0];
|
||||
s.port = isa.getPort();
|
||||
s.address = isa.getAddress();
|
||||
s.localport = localport;
|
||||
if (preferIPv4Stack && !(s.address instanceof Inet4Address))
|
||||
throw new SocketException("Protocol family not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
int socketAvailable() throws IOException {
|
||||
return impl.socketAvailable();
|
||||
int nativefd = checkAndReturnNativeFD();
|
||||
return available0(nativefd);
|
||||
}
|
||||
|
||||
void socketClose0(boolean useDeferredClose) throws IOException {
|
||||
impl.socketClose0(useDeferredClose);
|
||||
@Override
|
||||
void socketClose0(boolean useDeferredClose/*unused*/) throws IOException {
|
||||
if (fd == null)
|
||||
throw new SocketException("Socket closed");
|
||||
|
||||
if (!fd.valid())
|
||||
return;
|
||||
|
||||
final int nativefd = fdAccess.get(fd);
|
||||
fdAccess.set(fd, -1);
|
||||
close0(nativefd);
|
||||
}
|
||||
|
||||
@Override
|
||||
void socketShutdown(int howto) throws IOException {
|
||||
impl.socketShutdown(howto);
|
||||
int nativefd = checkAndReturnNativeFD();
|
||||
shutdown0(nativefd, howto);
|
||||
}
|
||||
|
||||
void socketSetOption(int cmd, boolean on, Object value)
|
||||
// Intentional fallthrough after SO_REUSEADDR
|
||||
@SuppressWarnings("fallthrough")
|
||||
@Override
|
||||
void socketSetOption(int opt, boolean on, Object value)
|
||||
throws SocketException {
|
||||
impl.socketSetOption(cmd, on, value);
|
||||
}
|
||||
|
||||
int socketGetOption(int opt, Object iaContainerObj) throws SocketException {
|
||||
return impl.socketGetOption(opt, iaContainerObj);
|
||||
}
|
||||
|
||||
void socketSendUrgentData(int data) throws IOException {
|
||||
impl.socketSendUrgentData(data);
|
||||
}
|
||||
|
||||
static boolean isReusePortAvailable() {
|
||||
// SO_REUSEPORT is not supported on Windows.
|
||||
return false;
|
||||
if (opt == SO_REUSEPORT) {
|
||||
throw new UnsupportedOperationException("unsupported option");
|
||||
}
|
||||
|
||||
int nativefd = checkAndReturnNativeFD();
|
||||
|
||||
if (opt == SO_TIMEOUT) {
|
||||
if (preferIPv4Stack) {
|
||||
// Don't enable the socket option on ServerSocket as it's
|
||||
// meaningless (we don't receive on a ServerSocket).
|
||||
if (serverSocket == null) {
|
||||
setSoTimeout0(nativefd, ((Integer)value).intValue());
|
||||
}
|
||||
} // else timeout is implemented through select.
|
||||
return;
|
||||
}
|
||||
|
||||
int optionValue = 0;
|
||||
|
||||
switch(opt) {
|
||||
case SO_REUSEADDR:
|
||||
if (useExclusiveBind) {
|
||||
// SO_REUSEADDR emulated when using exclusive bind
|
||||
isReuseAddress = on;
|
||||
return;
|
||||
}
|
||||
// intentional fallthrough
|
||||
case TCP_NODELAY:
|
||||
case SO_OOBINLINE:
|
||||
case SO_KEEPALIVE:
|
||||
optionValue = on ? 1 : 0;
|
||||
break;
|
||||
case SO_SNDBUF:
|
||||
case SO_RCVBUF:
|
||||
case IP_TOS:
|
||||
optionValue = ((Integer)value).intValue();
|
||||
break;
|
||||
case SO_LINGER:
|
||||
if (on) {
|
||||
optionValue = ((Integer)value).intValue();
|
||||
} else {
|
||||
optionValue = -1;
|
||||
}
|
||||
break;
|
||||
default :/* shouldn't get here */
|
||||
throw new SocketException("Option not supported");
|
||||
}
|
||||
|
||||
setIntOption(nativefd, opt, optionValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
int socketGetOption(int opt, Object iaContainerObj)
|
||||
throws SocketException {
|
||||
|
||||
// SO_REUSEPORT is not supported on Windows.
|
||||
if (opt == SO_REUSEPORT) {
|
||||
throw new UnsupportedOperationException("unsupported option");
|
||||
}
|
||||
|
||||
int nativefd = checkAndReturnNativeFD();
|
||||
|
||||
// SO_BINDADDR is not a socket option.
|
||||
if (opt == SO_BINDADDR) {
|
||||
localAddress(nativefd, (InetAddressContainer)iaContainerObj);
|
||||
return 0; // return value doesn't matter.
|
||||
}
|
||||
|
||||
// SO_REUSEADDR emulated when using exclusive bind
|
||||
if (opt == SO_REUSEADDR && useExclusiveBind)
|
||||
return isReuseAddress ? 1 : -1;
|
||||
|
||||
int value = getIntOption(nativefd, opt);
|
||||
|
||||
switch (opt) {
|
||||
case TCP_NODELAY:
|
||||
case SO_OOBINLINE:
|
||||
case SO_KEEPALIVE:
|
||||
case SO_REUSEADDR:
|
||||
return (value == 0) ? -1 : 1;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
void socketSendUrgentData(int data) throws IOException {
|
||||
int nativefd = checkAndReturnNativeFD();
|
||||
sendOOB(nativefd, data);
|
||||
}
|
||||
|
||||
private int checkAndReturnNativeFD() throws SocketException {
|
||||
if (fd == null || !fd.valid())
|
||||
throw new SocketException("Socket closed");
|
||||
|
||||
return fdAccess.get(fd);
|
||||
}
|
||||
|
||||
static final int WOULDBLOCK = -2; // Nothing available (non-blocking)
|
||||
|
||||
static {
|
||||
initIDs();
|
||||
}
|
||||
|
||||
/* Native methods */
|
||||
|
||||
static native void initIDs();
|
||||
|
||||
static native int socket0(boolean stream) throws IOException;
|
||||
|
||||
static native void bind0(int fd, InetAddress localAddress, int localport,
|
||||
boolean exclBind)
|
||||
throws IOException;
|
||||
|
||||
static native int connect0(int fd, InetAddress remote, int remotePort)
|
||||
throws IOException;
|
||||
|
||||
static native void waitForConnect(int fd, int timeout) throws IOException;
|
||||
|
||||
static native int localPort0(int fd) throws IOException;
|
||||
|
||||
static native void localAddress(int fd, InetAddressContainer in) throws SocketException;
|
||||
|
||||
static native void listen0(int fd, int backlog) throws IOException;
|
||||
|
||||
static native int accept0(int fd, InetSocketAddress[] isaa) throws IOException;
|
||||
|
||||
static native void waitForNewConnection(int fd, int timeout) throws IOException;
|
||||
|
||||
static native int available0(int fd) throws IOException;
|
||||
|
||||
static native void close0(int fd) throws IOException;
|
||||
|
||||
static native void shutdown0(int fd, int howto) throws IOException;
|
||||
|
||||
static native void setIntOption(int fd, int cmd, int optionValue) throws SocketException;
|
||||
|
||||
static native void setSoTimeout0(int fd, int timeout) throws SocketException;
|
||||
|
||||
static native int getIntOption(int fd, int cmd) throws SocketException;
|
||||
|
||||
static native void sendOOB(int fd, int data) throws IOException;
|
||||
|
||||
static native void configureBlocking(int fd, boolean blocking) throws IOException;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
#include "net_util.h"
|
||||
|
||||
#include "java_net_DualStackPlainSocketImpl.h"
|
||||
#include "java_net_PlainSocketImpl.h"
|
||||
#include "java_net_SocketOptions.h"
|
||||
|
||||
#define SET_BLOCKING 0
|
||||
|
@ -34,11 +34,11 @@ static jclass isa_class; /* java.net.InetSocketAddress */
|
|||
static jmethodID isa_ctorID; /* InetSocketAddress(InetAddress, int) */
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainSocketImpl
|
||||
* Class: java_net_PlainSocketImpl
|
||||
* Method: initIDs
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_initIDs
|
||||
JNIEXPORT void JNICALL Java_java_net_PlainSocketImpl_initIDs
|
||||
(JNIEnv *env, jclass clazz) {
|
||||
|
||||
jclass cls = (*env)->FindClass(env, "java/net/InetSocketAddress");
|
||||
|
@ -55,13 +55,13 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_initIDs
|
|||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainSocketImpl
|
||||
* Class: java_net_PlainSocketImpl
|
||||
* Method: socket0
|
||||
* Signature: (ZZ)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_socket0
|
||||
JNIEXPORT jint JNICALL Java_java_net_PlainSocketImpl_socket0
|
||||
(JNIEnv *env, jclass clazz, jboolean stream) {
|
||||
int fd, rv, opt=0;
|
||||
int fd, rv, opt = 0;
|
||||
int type = (stream ? SOCK_STREAM : SOCK_DGRAM);
|
||||
int domain = ipv6_available() ? AF_INET6 : AF_INET;
|
||||
|
||||
|
@ -86,11 +86,11 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_socket0
|
|||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainSocketImpl
|
||||
* Class: java_net_PlainSocketImpl
|
||||
* Method: bind0
|
||||
* Signature: (ILjava/net/InetAddress;I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_bind0
|
||||
JNIEXPORT void JNICALL Java_java_net_PlainSocketImpl_bind0
|
||||
(JNIEnv *env, jclass clazz, jint fd, jobject iaObj, jint port,
|
||||
jboolean exclBind)
|
||||
{
|
||||
|
@ -110,11 +110,11 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_bind0
|
|||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainSocketImpl
|
||||
* Class: java_net_PlainSocketImpl
|
||||
* Method: connect0
|
||||
* Signature: (ILjava/net/InetAddress;I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_connect0
|
||||
JNIEXPORT jint JNICALL Java_java_net_PlainSocketImpl_connect0
|
||||
(JNIEnv *env, jclass clazz, jint fd, jobject iaObj, jint port) {
|
||||
SOCKETADDRESS sa;
|
||||
int rv, sa_len = 0;
|
||||
|
@ -129,7 +129,7 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_connect0
|
|||
if (rv == SOCKET_ERROR) {
|
||||
int err = WSAGetLastError();
|
||||
if (err == WSAEWOULDBLOCK) {
|
||||
return java_net_DualStackPlainSocketImpl_WOULDBLOCK;
|
||||
return java_net_PlainSocketImpl_WOULDBLOCK;
|
||||
} else if (err == WSAEADDRNOTAVAIL) {
|
||||
JNU_ThrowByName(env, JNU_JAVANETPKG "ConnectException",
|
||||
"connect: Address is invalid on local machine,"
|
||||
|
@ -137,17 +137,17 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_connect0
|
|||
} else {
|
||||
NET_ThrowNew(env, err, "connect");
|
||||
}
|
||||
return -1; // return value not important.
|
||||
// return value not important.
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainSocketImpl
|
||||
* Class: java_net_PlainSocketImpl
|
||||
* Method: waitForConnect
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_waitForConnect
|
||||
JNIEXPORT void JNICALL Java_java_net_PlainSocketImpl_waitForConnect
|
||||
(JNIEnv *env, jclass clazz, jint fd, jint timeout) {
|
||||
int rv, retry;
|
||||
int optlen = sizeof(rv);
|
||||
|
@ -176,7 +176,7 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_waitForConnect
|
|||
if (rv == 0) {
|
||||
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
|
||||
"connect timed out");
|
||||
shutdown( fd, SD_BOTH );
|
||||
shutdown(fd, SD_BOTH);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_waitForConnect
|
|||
* yielding and retrying. As yielding is problematic in heavy
|
||||
* load conditions we attempt up to 3 times to get the error reason.
|
||||
*/
|
||||
for (retry=0; retry<3; retry++) {
|
||||
for (retry = 0; retry < 3; retry++) {
|
||||
NET_GetSockOpt(fd, SOL_SOCKET, SO_ERROR,
|
||||
(char*)&rv, &optlen);
|
||||
if (rv) {
|
||||
|
@ -219,11 +219,11 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_waitForConnect
|
|||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainSocketImpl
|
||||
* Class: java_net_PlainSocketImpl
|
||||
* Method: localPort0
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_localPort0
|
||||
JNIEXPORT jint JNICALL Java_java_net_PlainSocketImpl_localPort0
|
||||
(JNIEnv *env, jclass clazz, jint fd) {
|
||||
SOCKETADDRESS sa;
|
||||
int len = sizeof(sa);
|
||||
|
@ -241,11 +241,11 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_localPort0
|
|||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainSocketImpl
|
||||
* Class: java_net_PlainSocketImpl
|
||||
* Method: localAddress
|
||||
* Signature: (ILjava/net/InetAddressContainer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_localAddress
|
||||
JNIEXPORT void JNICALL Java_java_net_PlainSocketImpl_localAddress
|
||||
(JNIEnv *env, jclass clazz, jint fd, jobject iaContainerObj) {
|
||||
int port;
|
||||
SOCKETADDRESS sa;
|
||||
|
@ -267,13 +267,12 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_localAddress
|
|||
(*env)->SetObjectField(env, iaContainerObj, iaFieldID, iaObj);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainSocketImpl
|
||||
* Class: java_net_PlainSocketImpl
|
||||
* Method: listen0
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_listen0
|
||||
JNIEXPORT void JNICALL Java_java_net_PlainSocketImpl_listen0
|
||||
(JNIEnv *env, jclass clazz, jint fd, jint backlog) {
|
||||
if (listen(fd, backlog) == SOCKET_ERROR) {
|
||||
NET_ThrowNew(env, WSAGetLastError(), "listen failed");
|
||||
|
@ -281,13 +280,13 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_listen0
|
|||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainSocketImpl
|
||||
* Class: java_net_PlainSocketImpl
|
||||
* Method: accept0
|
||||
* Signature: (I[Ljava/net/InetSocketAddress;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_accept0
|
||||
JNIEXPORT jint JNICALL Java_java_net_PlainSocketImpl_accept0
|
||||
(JNIEnv *env, jclass clazz, jint fd, jobjectArray isaa) {
|
||||
int newfd, port=0;
|
||||
int newfd, port = 0;
|
||||
jobject isa;
|
||||
jobject ia;
|
||||
SOCKETADDRESS sa;
|
||||
|
@ -315,11 +314,11 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_accept0
|
|||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainSocketImpl
|
||||
* Class: java_net_PlainSocketImpl
|
||||
* Method: waitForNewConnection
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_waitForNewConnection
|
||||
JNIEXPORT void JNICALL Java_java_net_PlainSocketImpl_waitForNewConnection
|
||||
(JNIEnv *env, jclass clazz, jint fd, jint timeout) {
|
||||
int rv;
|
||||
|
||||
|
@ -336,11 +335,11 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_waitForNewConnecti
|
|||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainSocketImpl
|
||||
* Class: java_net_PlainSocketImpl
|
||||
* Method: available0
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_available0
|
||||
JNIEXPORT jint JNICALL Java_java_net_PlainSocketImpl_available0
|
||||
(JNIEnv *env, jclass clazz, jint fd) {
|
||||
jint available = -1;
|
||||
|
||||
|
@ -352,33 +351,32 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_available0
|
|||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainSocketImpl
|
||||
* Class: java_net_PlainSocketImpl
|
||||
* Method: close0
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_close0
|
||||
JNIEXPORT void JNICALL Java_java_net_PlainSocketImpl_close0
|
||||
(JNIEnv *env, jclass clazz, jint fd) {
|
||||
NET_SocketClose(fd);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainSocketImpl
|
||||
* Class: java_net_PlainSocketImpl
|
||||
* Method: shutdown0
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_shutdown0
|
||||
JNIEXPORT void JNICALL Java_java_net_PlainSocketImpl_shutdown0
|
||||
(JNIEnv *env, jclass clazz, jint fd, jint howto) {
|
||||
shutdown(fd, howto);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainSocketImpl
|
||||
* Class: java_net_PlainSocketImpl
|
||||
* Method: setIntOption
|
||||
* Signature: (III)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_java_net_DualStackPlainSocketImpl_setIntOption
|
||||
Java_java_net_PlainSocketImpl_setIntOption
|
||||
(JNIEnv *env, jclass clazz, jint fd, jint cmd, jint value)
|
||||
{
|
||||
int level = 0, opt = 0;
|
||||
|
@ -412,12 +410,12 @@ Java_java_net_DualStackPlainSocketImpl_setIntOption
|
|||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainSocketImpl
|
||||
* Class: java_net_PlainSocketImpl
|
||||
* Method: setSoTimeout0
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_java_net_DualStackPlainSocketImpl_setSoTimeout0
|
||||
Java_java_net_PlainSocketImpl_setSoTimeout0
|
||||
(JNIEnv *env, jclass clazz, jint fd, jint timeout)
|
||||
{
|
||||
/*
|
||||
|
@ -457,15 +455,15 @@ Java_java_net_DualStackPlainSocketImpl_setSoTimeout0
|
|||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainSocketImpl
|
||||
* Class: java_net_PlainSocketImpl
|
||||
* Method: getIntOption
|
||||
* Signature: (II)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_getIntOption
|
||||
JNIEXPORT jint JNICALL Java_java_net_PlainSocketImpl_getIntOption
|
||||
(JNIEnv *env, jclass clazz, jint fd, jint cmd)
|
||||
{
|
||||
int level = 0, opt = 0;
|
||||
int result=0;
|
||||
int result = 0;
|
||||
struct linger linger = {0, 0};
|
||||
char *arg;
|
||||
int arglen;
|
||||
|
@ -494,13 +492,12 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_getIntOption
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainSocketImpl
|
||||
* Class: java_net_PlainSocketImpl
|
||||
* Method: sendOOB
|
||||
* Signature: (II)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_sendOOB
|
||||
JNIEXPORT void JNICALL Java_java_net_PlainSocketImpl_sendOOB
|
||||
(JNIEnv *env, jclass clazz, jint fd, jint data) {
|
||||
jint n;
|
||||
unsigned char d = (unsigned char) data & 0xff;
|
||||
|
@ -512,11 +509,11 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_sendOOB
|
|||
}
|
||||
|
||||
/*
|
||||
* Class: java_net_DualStackPlainSocketImpl
|
||||
* Class: java_net_PlainSocketImpl
|
||||
* Method: configureBlocking
|
||||
* Signature: (IZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_configureBlocking
|
||||
JNIEXPORT void JNICALL Java_java_net_PlainSocketImpl_configureBlocking
|
||||
(JNIEnv *env, jclass clazz, jint fd, jboolean blocking) {
|
||||
u_long arg;
|
||||
int result;
|
Loading…
Add table
Add a link
Reference in a new issue