当前位置: 首页>>代码示例>>Java>>正文


Java Socket.setPerformancePreferences方法代码示例

本文整理汇总了Java中java.net.Socket.setPerformancePreferences方法的典型用法代码示例。如果您正苦于以下问题:Java Socket.setPerformancePreferences方法的具体用法?Java Socket.setPerformancePreferences怎么用?Java Socket.setPerformancePreferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.net.Socket的用法示例。


在下文中一共展示了Socket.setPerformancePreferences方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setProperties

import java.net.Socket; //导入方法依赖的package包/类
public void setProperties(Socket socket) throws SocketException{
    if (rxBufSize != null)
        socket.setReceiveBufferSize(rxBufSize.intValue());
    if (txBufSize != null)
        socket.setSendBufferSize(txBufSize.intValue());
    if (ooBInline !=null)
        socket.setOOBInline(ooBInline.booleanValue());
    if (soKeepAlive != null)
        socket.setKeepAlive(soKeepAlive.booleanValue());
    if (performanceConnectionTime != null && performanceLatency != null &&
            performanceBandwidth != null)
        socket.setPerformancePreferences(
                performanceConnectionTime.intValue(),
                performanceLatency.intValue(),
                performanceBandwidth.intValue());
    if (soReuseAddress != null)
        socket.setReuseAddress(soReuseAddress.booleanValue());
    if (soLingerOn != null && soLingerTime != null)
        socket.setSoLinger(soLingerOn.booleanValue(),
                soLingerTime.intValue());
    if (soTimeout != null && soTimeout.intValue() >= 0)
        socket.setSoTimeout(soTimeout.intValue());
    if (tcpNoDelay != null)
        socket.setTcpNoDelay(tcpNoDelay.booleanValue());
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:26,代码来源:SocketProperties.java

示例2: send

import java.net.Socket; //导入方法依赖的package包/类
private synchronized void send(Message message) throws IOException {
	if(message == null) return;
			
	Socket socket = new Socket();
	socket.setReuseAddress(true);
	socket.setPerformancePreferences(2, 1, 0); // connection, latency, bandwidth
	socket.setTcpNoDelay(true);
	socket.setTrafficClass(0x10);	// low delay
	socket.setSoTimeout(timeoutMillis);
	socket.connect(address);
		
	@SuppressWarnings("resource")
       OutputStream out = socket.getOutputStream();
	
	// TODO additional check. Is it needed?
	if(out == null) throw new IOException("Socket has no output stream.");
	
	String text = message.toString();
	out.write(text.getBytes());
	
	if(CRUSH.debug) CRUSH.debug(this, "DRP> " + text);
	
	out.flush();
	socket.close();
}
 
开发者ID:attipaci,项目名称:crush,代码行数:26,代码来源:DRPMessenger.java

示例3: setProperties

import java.net.Socket; //导入方法依赖的package包/类
public void setProperties(Socket socket) throws SocketException {
	if (rxBufSize != null)
		socket.setReceiveBufferSize(rxBufSize.intValue());
	if (txBufSize != null)
		socket.setSendBufferSize(txBufSize.intValue());
	if (ooBInline != null)
		socket.setOOBInline(ooBInline.booleanValue());
	if (soKeepAlive != null)
		socket.setKeepAlive(soKeepAlive.booleanValue());
	if (performanceConnectionTime != null && performanceLatency != null && performanceBandwidth != null)
		socket.setPerformancePreferences(performanceConnectionTime.intValue(), performanceLatency.intValue(),
				performanceBandwidth.intValue());
	if (soReuseAddress != null)
		socket.setReuseAddress(soReuseAddress.booleanValue());
	if (soLingerOn != null && soLingerTime != null)
		socket.setSoLinger(soLingerOn.booleanValue(), soLingerTime.intValue());
	if (soTimeout != null && soTimeout.intValue() >= 0)
		socket.setSoTimeout(soTimeout.intValue());
	if (tcpNoDelay != null)
		socket.setTcpNoDelay(tcpNoDelay.booleanValue());
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:22,代码来源:SocketProperties.java


注:本文中的java.net.Socket.setPerformancePreferences方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。