33 * This class defines the plain SocketImpl that is used on Windows platforms
34 * greater or equal to Windows Vista. These platforms have a dual
35 * layer TCP/IP stack and can handle both IPv4 and IPV6 through a
36 * single file descriptor.
37 *
38 * @author Chris Hegarty
39 */
40
41 class DualStackPlainSocketImpl extends AbstractPlainSocketImpl
42 {
43 static JavaIOFileDescriptorAccess fdAccess = SharedSecrets.getJavaIOFileDescriptorAccess();
44
45
46 // true if this socket is exclusively bound
47 private final boolean exclusiveBind;
48
49 // emulates SO_REUSEADDR when exclusiveBind is true
50 private boolean isReuseAddress;
51
52 static {
53 initIDs();
54 }
55
56 public DualStackPlainSocketImpl(boolean exclBind) {
57 exclusiveBind = exclBind;
58 }
59
60 public DualStackPlainSocketImpl(FileDescriptor fd, boolean exclBind) {
61 this.fd = fd;
62 exclusiveBind = exclBind;
63 }
64
65 @Override
66 void socketBind(InetAddress address, int port) throws IOException {
67 int nativefd = checkAndReturnNativeFD();
68
69 if (address == null)
70 throw new NullPointerException("inet address argument is null.");
71
72 bind0(nativefd, address, port, exclusiveBind);
73 if (port == 0) {
110 break;
111 case SO_SNDBUF :
112 case SO_RCVBUF :
113 case IP_TOS :
114 optionValue = ((Integer)value).intValue();
115 break;
116 case SO_LINGER :
117 if (on) {
118 optionValue = ((Integer)value).intValue();
119 } else {
120 optionValue = -1;
121 }
122 break;
123 default :/* shouldn't get here */
124 throw new SocketException("Option not supported");
125 }
126
127 setIntOption(nativefd, opt, optionValue);
128 }
129
130 static native void initIDs();
131
132 void socketCreate(boolean stream) throws IOException {
133 if (fd == null)
134 throw new SocketException("Socket closed");
135
136 int newfd = socket0(stream, false /*v6 Only*/);
137
138 fdAccess.set(fd, newfd);
139 }
140 static native int socket0(boolean stream, boolean v6Only) throws IOException;
141
142 void socketConnect(InetAddress address, int port, int timeout)
143 throws IOException {
144 int nativefd = checkAndReturnNativeFD();
145
146 if (address == null)
147 throw new NullPointerException("inet address argument is null.");
148
149 int connectResult;
150 if (timeout <= 0) {
|
33 * This class defines the plain SocketImpl that is used on Windows platforms
34 * greater or equal to Windows Vista. These platforms have a dual
35 * layer TCP/IP stack and can handle both IPv4 and IPV6 through a
36 * single file descriptor.
37 *
38 * @author Chris Hegarty
39 */
40
41 class DualStackPlainSocketImpl extends AbstractPlainSocketImpl
42 {
43 static JavaIOFileDescriptorAccess fdAccess = SharedSecrets.getJavaIOFileDescriptorAccess();
44
45
46 // true if this socket is exclusively bound
47 private final boolean exclusiveBind;
48
49 // emulates SO_REUSEADDR when exclusiveBind is true
50 private boolean isReuseAddress;
51
52 static {
53 initProto();
54 }
55
56 public DualStackPlainSocketImpl(boolean exclBind) {
57 exclusiveBind = exclBind;
58 }
59
60 public DualStackPlainSocketImpl(FileDescriptor fd, boolean exclBind) {
61 this.fd = fd;
62 exclusiveBind = exclBind;
63 }
64
65 @Override
66 void socketBind(InetAddress address, int port) throws IOException {
67 int nativefd = checkAndReturnNativeFD();
68
69 if (address == null)
70 throw new NullPointerException("inet address argument is null.");
71
72 bind0(nativefd, address, port, exclusiveBind);
73 if (port == 0) {
110 break;
111 case SO_SNDBUF :
112 case SO_RCVBUF :
113 case IP_TOS :
114 optionValue = ((Integer)value).intValue();
115 break;
116 case SO_LINGER :
117 if (on) {
118 optionValue = ((Integer)value).intValue();
119 } else {
120 optionValue = -1;
121 }
122 break;
123 default :/* shouldn't get here */
124 throw new SocketException("Option not supported");
125 }
126
127 setIntOption(nativefd, opt, optionValue);
128 }
129
130 static native void initProto();
131
132 void socketCreate(boolean stream) throws IOException {
133 if (fd == null)
134 throw new SocketException("Socket closed");
135
136 int newfd = socket0(stream, false /*v6 Only*/);
137
138 fdAccess.set(fd, newfd);
139 }
140 static native int socket0(boolean stream, boolean v6Only) throws IOException;
141
142 void socketConnect(InetAddress address, int port, int timeout)
143 throws IOException {
144 int nativefd = checkAndReturnNativeFD();
145
146 if (address == null)
147 throw new NullPointerException("inet address argument is null.");
148
149 int connectResult;
150 if (timeout <= 0) {
|