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


Java Socket.setReceiveTimeOut方法代码示例

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


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

示例1: main

import org.zeromq.ZMQ.Socket; //导入方法依赖的package包/类
/**
 * Send a string using ZMQ. The program has been originally used for sending control messages in Idommar.
 * @param args
 */
public static void main(String[] args) throws Exception {

	if ( args.length < 2 ) {
		System.out.println("missing parameters");
		return;
	}

	try {
		// read the command line arguments and create a ZMQ context.
		String address = args[0];
		String command = args[1];
		Context context = ZMQ.context(1);
		Socket controlSocket = context.socket(ZMQ.REQ);
		//System.out.println("ALGO: ZMQ created context");
		
		// configure the ZMQ connection
		controlSocket.setReceiveTimeOut(10000);
		controlSocket.connect(address);
		
		// send the command
		controlSocket.send(command);
		//System.out.println("ZMQ connected to socket");
		
		// close the socket and terminate the context.
		controlSocket.close();
		context.term();
	} catch (Exception e) {
		e.printStackTrace();
		System.exit(0);
	}
}
 
开发者ID:jasjisdo,项目名称:spark-newsreel-recommender,代码行数:36,代码来源:StringSender.java

示例2: connect

import org.zeromq.ZMQ.Socket; //导入方法依赖的package包/类
protected Socket connect(final AbstractChannel channel)
{
    final Socket zmqSocket = zmqContext.createSocket(channel.getZmqSocketType());
    zmqSocket.setLinger(1000L);
    zmqSocket.setReceiveTimeOut(receiveTimeoutMillis);
    zmqSocket.connect(channel.getAddress());

    channels.add(channel);
    LOGGER.info("Connected channel: {} {}", channel.getClass().getSimpleName(), channel.getAddress());

    return zmqSocket;
}
 
开发者ID:openanalytics,项目名称:japyter,代码行数:13,代码来源:Session.java


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