因为netty
对SCTP和TCP使用不同的 channel 初始化,所以我想检查平台是否支持SCTP,如果支持,则使用SCTP,否则使用TCP。但是,我在 JDK8 或 netty4 中都找不到任何方法来检查这一点。
最佳答案
如果 sctp 可用,则应该可以毫无异常(exception)地调用 com.sun.nio.sctp.SctpServerChannel
,但我无法确认这一点,因为我在所有设备上都支持 sctp。
To ensure that you have a correctly configured machine and JDK, try compiling and running the following application:
public class TestSCTP
{
public static void main(String[] args) throws Exception {
com.sun.nio.sctp.SctpChannel sc = com.sun.nio.sctp.SctpChannel.open();
}
}
$ jdk1.7.0/bin/javac TestSCTP.java
$ jdk1.7.0/bin/java TestSCTP
If it compiles and runs without any errors, then congratulations you have a correctly configured machine and JDK. You can now start writing applications that use the SCTP API.
关于java-8 - Java 检查平台是否支持 sctp,否则使用 tcp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49724997/