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


Java Socket.setLinger方法代码示例

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


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

示例1: destroySocket

import org.zeromq.ZMQ.Socket; //导入方法依赖的package包/类
/**
 * Destroys managed socket within this context and remove from sockets list
 * 
 * @param s org.zeromq.Socket object to destroy
 */
public void destroySocket(Socket s) {
    if (s == null)
        return;

    if (sockets.contains(s)) {
        try {
            s.setLinger(linger);
        } catch (ZMQException e) {
            if (e.getErrorCode() != ZMQ.ETERM()) {
                throw e;
            }
        }
        s.close();
        sockets.remove(s);
    }
}
 
开发者ID:zeromq,项目名称:jzmq3-x,代码行数:22,代码来源:ZContext.java

示例2: testPollerUnregister

import org.zeromq.ZMQ.Socket; //导入方法依赖的package包/类
@Test
public void testPollerUnregister() {
    Context context = ZMQ.context(1);
    Socket socketOne = context.socket(ZMQ.SUB);
    Socket socketTwo = context.socket(ZMQ.REP);
    Poller poller = new ZMQ.Poller(2);
    poller.register(socketOne, ZMQ.Poller.POLLIN);
    poller.register(socketTwo, ZMQ.Poller.POLLIN);

    socketOne.setLinger(0);
    socketOne.close();
    socketTwo.setLinger(0);
    socketTwo.close();

    poller.unregister(socketOne);
    poller.unregister(socketTwo);
    
    context.term();
}
 
开发者ID:zeromq,项目名称:jzmq3-x,代码行数:20,代码来源:ZMQTest.java

示例3: 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

示例4: destroySocket

import org.zeromq.ZMQ.Socket; //导入方法依赖的package包/类
/**
 * Destroys managed socket within this context
 * and remove from sockets list
 * @param s
 *          org.zeromq.Socket object to destroy
 */
public void destroySocket(Socket s) {
    if (s == null)
        return;
    
    if (sockets.contains(s)) {
        try {
            s.setLinger(linger);
        } catch (ZError.CtxTerminatedException e) {}
        s.close();
        sockets.remove(s);
    }
}
 
开发者ID:zeromq,项目名称:jeromq3-x,代码行数:19,代码来源:ZContext.java

示例5: buildZPipe

import org.zeromq.ZMQ.Socket; //导入方法依赖的package包/类
public static List<Socket> buildZPipe(Context ctx) {
    Socket socket1 = ctx.socket(ZMQ.PAIR);
    socket1.setLinger(0);
    socket1.setHWM(1);

    Socket socket2 = ctx.socket(ZMQ.PAIR);
    socket2.setLinger(0);
    socket2.setHWM(1);

    String iface = "inproc://" + new BigInteger(130, rand).toString(32);
    socket1.bind(iface);
    socket2.connect(iface);

    return Arrays.asList(socket1, socket2);
}
 
开发者ID:zeromq,项目名称:jeromq3-x,代码行数:16,代码来源:ZHelper.java

示例6: main

import org.zeromq.ZMQ.Socket; //导入方法依赖的package包/类
public static void main (String[] args) {
    Context context = ZMQ.context(1);

    //  Socket to talk to clients
    Socket publisher = context.socket(ZMQ.PUB);
    publisher.setLinger(5000);
    // In 0MQ 3.x pub socket could drop messages if sub can follow the generation of pub messages
    publisher.setSndHWM(0);
    publisher.bind("tcp://*:5561");

    //  Socket to receive signals
    Socket syncservice = context.socket(ZMQ.REP);
    syncservice.bind("tcp://*:5562");

    System.out.println("Waiting subscribers");
    //  Get synchronization from subscribers
    int subscribers = 0;
    while (subscribers < SUBSCRIBERS_EXPECTED) {
        //  - wait for synchronization request
        syncservice.recv(0);

        //  - send synchronization reply
        syncservice.send("", 0);
        subscribers++;
    }
    //  Now broadcast exactly 1M updates followed by END
    System.out.println ("Broadcasting messages");

    int update_nbr;
    for (update_nbr = 0; update_nbr < 1000000; update_nbr++){
        publisher.send("Rhubarb", 0);
    }

    publisher.send("END", 0);

    // clean up
    publisher.close();
    syncservice.close();
    context.term();
}
 
开发者ID:zeromq,项目名称:jeromq3-x,代码行数:41,代码来源:syncpub.java

示例7: set_linger

import org.zeromq.ZMQ.Socket; //导入方法依赖的package包/类
public static Socket set_linger(Socket socket, long linger_ms) {
	socket.setLinger(linger_ms);
	return socket;
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:5,代码来源:ZeroMq.java


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