本文整理了Java中java.net.Socket.getTrafficClass()
方法的一些代码示例,展示了Socket.getTrafficClass()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Socket.getTrafficClass()
方法的具体详情如下:
包路径:java.net.Socket
类名称:Socket
方法名:getTrafficClass
[英]Returns this socket's SocketOptions#IP_TOS setting.
[中]返回此套接字的SocketOptions#IP#TOS设置。
代码示例来源:origin: aws/aws-sdk-java
@Override
public int getTrafficClass() throws SocketException {
return sock.getTrafficClass();
}
代码示例来源:origin: netty/netty
@Override
public int getTrafficClass() {
try {
return javaSocket.getTrafficClass();
} catch (SocketException e) {
throw new ChannelException(e);
}
}
代码示例来源:origin: redisson/redisson
@Override
public int getTrafficClass() {
try {
return javaSocket.getTrafficClass();
} catch (SocketException e) {
throw new ChannelException(e);
}
}
代码示例来源:origin: apache/zookeeper
/**
* See {@link Socket#getTrafficClass()}. Calling this method does not trigger mode detection.
*/
@Override
public int getTrafficClass() throws SocketException {
return getSocketAllowUnknownMode().getTrafficClass();
}
代码示例来源:origin: wildfly/wildfly
@Override
public int getTrafficClass() {
try {
return javaSocket.getTrafficClass();
} catch (SocketException e) {
throw new ChannelException(e);
}
}
代码示例来源:origin: io.netty/netty
public int getTrafficClass() {
try {
return socket.getTrafficClass();
} catch (SocketException e) {
throw new ChannelException(e);
}
}
代码示例来源:origin: apache/activemq
/**
* The Differentiated Services values use only 6 of the 8 bits in the field
* in the TCP/IP packet header. Make sure any values the system has set for
* the other two bits (the ECN bits) are maintained.
*
* @param dscp The Differentiated Services Code Point.
* @return A Differentiated Services Code Point that respects the ECN bits
* set on the system.
* @throws IllegalArgumentException if setting Differentiated Services is
* not supported.
*/
private static int adjustDSCPForECN(int dscp)
throws IllegalArgumentException {
// The only way to see if there are any values set for the ECN is to
// read the traffic class automatically set by the system and isolate
// the ECN bits.
Socket socket = new Socket();
try {
int systemTrafficClass = socket.getTrafficClass();
// The 1st and 2nd bits of the system traffic class are the ECN
// bits.
return (dscp << 2) | (systemTrafficClass & 3);
} catch (SocketException e) {
throw new IllegalArgumentException("Setting Differentiated Services"
+ " not supported: " + e);
}
}
}
代码示例来源:origin: apache/activemq
int resultTrafficClass = sock.getTrafficClass();
if (this.trafficClass != resultTrafficClass) {
代码示例来源:origin: wildfly/wildfly
public <T> T getOption(final Option<T> option) throws IOException {
if (option == Options.CLOSE_ABORT) {
return option.cast(Boolean.valueOf(conduit.getSocketChannel().socket().getSoLinger() == 0));
} else if (option == Options.IP_TRAFFIC_CLASS) {
return option.cast(Integer.valueOf(conduit.getSocketChannel().socket().getTrafficClass()));
} else if (option == Options.KEEP_ALIVE) {
return option.cast(Boolean.valueOf(conduit.getSocketChannel().socket().getKeepAlive()));
} else if (option == Options.READ_TIMEOUT) {
return option.cast(Integer.valueOf(conduit.getReadTimeout()));
} else if (option == Options.RECEIVE_BUFFER) {
return option.cast(Integer.valueOf(conduit.getSocketChannel().socket().getReceiveBufferSize()));
} else if (option == Options.SEND_BUFFER) {
return option.cast(Integer.valueOf(conduit.getSocketChannel().socket().getSendBufferSize()));
} else if (option == Options.TCP_NODELAY) {
return option.cast(Boolean.valueOf(conduit.getSocketChannel().socket().getTcpNoDelay()));
} else if (option == Options.TCP_OOB_INLINE) {
return option.cast(Boolean.valueOf(conduit.getSocketChannel().socket().getOOBInline()));
} else if (option == Options.WRITE_TIMEOUT) {
return option.cast(Integer.valueOf(conduit.getWriteTimeout()));
} else {
return null;
}
}
代码示例来源:origin: wildfly/wildfly
conduit.getSocketChannel().socket().setSoLinger(Options.CLOSE_ABORT.cast(value, Boolean.FALSE).booleanValue(), 0);
} else if (option == Options.IP_TRAFFIC_CLASS) {
result = option.cast(Integer.valueOf(conduit.getSocketChannel().socket().getTrafficClass()));
conduit.getSocketChannel().socket().setTrafficClass(Options.IP_TRAFFIC_CLASS.cast(value).intValue());
} else if (option == Options.KEEP_ALIVE) {
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testSocketTrafficClass() throws IOException {
Assume.assumeTrue("Run only on Java 7", System.getProperty("java.specification.version").equals("1.7"));
Assume.assumeFalse("Do not run on Travis CI", "true".equals(System.getenv("TRAVIS")));
final SocketAppender appender = loggerContextRule.getAppender("socket", SocketAppender.class);
final TcpSocketManager manager = (TcpSocketManager) appender.getManager();
final Socket socket = manager.getSocket();
Assert.assertEquals(Rfc1349TrafficClass.IPTOS_LOWCOST.value(), socket.getTrafficClass());
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testSocketTrafficClass() throws IOException {
Assume.assumeTrue("Run only on Java 7", System.getProperty("java.specification.version").equals("1.7"));
Assume.assumeFalse("Do not run on Travis CI", "true".equals(System.getenv("TRAVIS")));
final SocketAppender appender = loggerContextRule.getAppender("socket", SocketAppender.class);
final TcpSocketManager manager = (TcpSocketManager) appender.getManager();
final Socket socket = manager.getSocket();
Assert.assertEquals(Rfc1349TrafficClass.IPTOS_LOWCOST.value(), socket.getTrafficClass());
}
}
代码示例来源:origin: stackoverflow.com
return delegate.getTrafficClass();
代码示例来源:origin: stackoverflow.com
return delegate.getTrafficClass();
代码示例来源:origin: stackoverflow.com
return delegate.getTrafficClass();
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
@Override
public int getTrafficClass() throws SocketException {
return sock.getTrafficClass();
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Override
public int getTrafficClass() throws SocketException {
return socket.getTrafficClass();
}
代码示例来源:origin: com.sun.mail/javax.mail
@Override
public int getTrafficClass() throws SocketException {
return socket.getTrafficClass();
}
代码示例来源:origin: spring-projects/spring-integration
public int getTrafficClass() throws SocketException {
return this.socket.getTrafficClass();
}
代码示例来源:origin: apache/mina
/**
* {@inheritDoc}
*/
@Override
public int getTrafficClass() {
try {
return socket.getTrafficClass();
} catch (SocketException e) {
throw new ConfigurationException(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!