Java_java_net_PlainSocketImpl_socketSetOption
Java_java_net_PlainSocketImpl_socketSetOption
打开-jdk-8 :
这个jin函数:Java_java_net_PlainSocketImpl_socketSetOption:
/*
* SO_TIMEOUT is a no-op on Solaris/Linux
*/
if (cmd == java_net_SocketOptions_SO_TIMEOUT) {
return;
}
文件:openjdk7/jdk/src/solaris/native/java/net/PlainSocketImpl.c
这是否意味着 SO_TIMEOUT 的 linux setOption 将被忽略?
我找不到 linux 的金币。但是 solaris 的代码似乎也适用于 linux .
不,这只是意味着它没有作为套接字选项实现。有些平台不支持它。在那些平台上 select()
or friends are used.
solaris 文件夹中的源也用于 Linux。
SO_TIMEOUT
在 Java_java_net_PlainSocketImpl_socketSetOption0
中被忽略。但是 timeout
在调用 AbstractPlainSocketImpl.setOption
时保留为一个字段:
case SO_TIMEOUT:
if (val == null || (!(val instanceof Integer)))
throw new SocketException("Bad parameter for SO_TIMEOUT");
int tmp = ((Integer) val).intValue();
if (tmp < 0)
throw new IllegalArgumentException("timeout < 0");
// Saved for later use
timeout = tmp;
break;
并且timeout
在读取SocketInputStream
时使用:
public int read(byte b[], int off, int length) throws IOException {
return read(b, off, length, impl.getTimeout());
}
打开-jdk-8 :
这个jin函数:Java_java_net_PlainSocketImpl_socketSetOption:
/*
* SO_TIMEOUT is a no-op on Solaris/Linux
*/
if (cmd == java_net_SocketOptions_SO_TIMEOUT) {
return;
}
文件:openjdk7/jdk/src/solaris/native/java/net/PlainSocketImpl.c
这是否意味着 SO_TIMEOUT 的 linux setOption 将被忽略?
我找不到 linux 的金币。但是 solaris 的代码似乎也适用于 linux .
不,这只是意味着它没有作为套接字选项实现。有些平台不支持它。在那些平台上 select()
or friends are used.
solaris 文件夹中的源也用于 Linux。
SO_TIMEOUT
在 Java_java_net_PlainSocketImpl_socketSetOption0
中被忽略。但是 timeout
在调用 AbstractPlainSocketImpl.setOption
时保留为一个字段:
case SO_TIMEOUT:
if (val == null || (!(val instanceof Integer)))
throw new SocketException("Bad parameter for SO_TIMEOUT");
int tmp = ((Integer) val).intValue();
if (tmp < 0)
throw new IllegalArgumentException("timeout < 0");
// Saved for later use
timeout = tmp;
break;
并且timeout
在读取SocketInputStream
时使用:
public int read(byte b[], int off, int length) throws IOException {
return read(b, off, length, impl.getTimeout());
}