< prev index next >
src/java.base/windows/classes/java/net/PlainSocketImpl.java
Print this page
rev 49701 : [mq]: 8201510-Merge-TwoStacksPlainSocketImpl-into-DualStackPlainSocketImpl
*** 23,91 ****
* questions.
*/
package java.net;
import java.io.*;
- import java.security.AccessController;
- import java.security.PrivilegedAction;
- import sun.security.action.GetPropertyAction;
/*
* This class PlainSocketImpl simply delegates to the appropriate real
* SocketImpl. We do this because PlainSocketImpl is already extended
* by SocksSocketImpl.
* <p>
! * There are two possibilities for the real SocketImpl,
! * TwoStacksPlainSocketImpl or DualStackPlainSocketImpl. We use
! * DualStackPlainSocketImpl on systems that have a dual stack
! * TCP implementation. Otherwise we create an instance of
! * TwoStacksPlainSocketImpl and delegate to it.
*
* @author Chris Hegarty
*/
class PlainSocketImpl extends AbstractPlainSocketImpl {
private AbstractPlainSocketImpl impl;
- /* java.net.preferIPv4Stack */
- private static final boolean preferIPv4Stack;
-
- /* True if exclusive binding is on for Windows */
- private static final boolean exclusiveBind;
-
- static {
- preferIPv4Stack = Boolean.parseBoolean(
- AccessController.doPrivileged(
- new GetPropertyAction("java.net.preferIPv4Stack")));
-
- String exclBindProp = AccessController.doPrivileged(
- new GetPropertyAction("sun.net.useExclusiveBind", ""));
- exclusiveBind = (exclBindProp.isEmpty())
- ? true
- : Boolean.parseBoolean(exclBindProp);
- }
-
/**
* Constructs an empty instance.
*/
PlainSocketImpl() {
! if (!preferIPv4Stack) {
! impl = new DualStackPlainSocketImpl(exclusiveBind);
! } else {
! impl = new TwoStacksPlainSocketImpl(exclusiveBind);
! }
}
/**
* Constructs an instance with the given file descriptor.
*/
PlainSocketImpl(FileDescriptor fd) {
! if (!preferIPv4Stack) {
! impl = new DualStackPlainSocketImpl(fd, exclusiveBind);
! } else {
! impl = new TwoStacksPlainSocketImpl(fd, exclusiveBind);
! }
}
// Override methods in SocketImpl that access impl's fields.
protected FileDescriptor getFileDescriptor() {
--- 23,58 ----
* questions.
*/
package java.net;
import java.io.*;
/*
* 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.
*
* @author Chris Hegarty
*/
class PlainSocketImpl extends AbstractPlainSocketImpl {
private AbstractPlainSocketImpl impl;
/**
* Constructs an empty instance.
*/
PlainSocketImpl() {
! impl = new DualStackPlainSocketImpl();
}
/**
* Constructs an instance with the given file descriptor.
*/
PlainSocketImpl(FileDescriptor fd) {
! impl = new DualStackPlainSocketImpl(fd);
}
// Override methods in SocketImpl that access impl's fields.
protected FileDescriptor getFileDescriptor() {
*** 146,167 ****
protected void connect(SocketAddress address, int timeout) throws IOException {
impl.connect(address, timeout);
}
public void setOption(int opt, Object val) throws SocketException {
- if (opt == SocketOptions.SO_REUSEPORT) {
- // SO_REUSEPORT is not supported on Windows.
- throw new UnsupportedOperationException("unsupported option");
- }
impl.setOption(opt, val);
}
public Object getOption(int opt) throws SocketException {
- if (opt == SocketOptions.SO_REUSEPORT) {
- // SO_REUSEPORT is not supported on Windows.
- throw new UnsupportedOperationException("unsupported option");
- }
return impl.getOption(opt);
}
synchronized void doConnect(InetAddress address, int port, int timeout) throws IOException {
impl.doConnect(address, port, timeout);
--- 113,126 ----
*** 269,280 ****
return impl.getTimeout();
}
// Override methods in AbstractPlainSocketImpl that need to be implemented.
! void socketCreate(boolean isServer) throws IOException {
! impl.socketCreate(isServer);
}
void socketConnect(InetAddress address, int port, int timeout)
throws IOException {
impl.socketConnect(address, port, timeout);
--- 228,239 ----
return impl.getTimeout();
}
// Override methods in AbstractPlainSocketImpl that need to be implemented.
! void socketCreate(boolean stream) throws IOException {
! impl.socketCreate(stream);
}
void socketConnect(InetAddress address, int port, int timeout)
throws IOException {
impl.socketConnect(address, port, timeout);
*** 305,326 ****
impl.socketShutdown(howto);
}
void socketSetOption(int cmd, boolean on, Object value)
throws SocketException {
- if (cmd == SocketOptions.SO_REUSEPORT) {
- // SO_REUSEPORT is not supported on Windows.
- throw new UnsupportedOperationException("unsupported option");
- }
impl.socketSetOption(cmd, on, value);
}
int socketGetOption(int opt, Object iaContainerObj) throws SocketException {
- if (opt == SocketOptions.SO_REUSEPORT) {
- // SO_REUSEPORT is not supported on Windows.
- throw new UnsupportedOperationException("unsupported option");
- }
return impl.socketGetOption(opt, iaContainerObj);
}
void socketSendUrgentData(int data) throws IOException {
impl.socketSendUrgentData(data);
--- 264,277 ----
< prev index next >