本文整理汇总了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);
}
}
示例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;
}