Package org.zeromq.ZMQ

Examples of org.zeromq.ZMQ.Socket.bind()


    public static Socket fork(ZContext ctx, IAttachedRunnable runnable, Object... args) {
        Socket pipe = ctx.createSocket(ZMQ.PAIR);

        if (pipe != null) {
            pipe.bind(String.format("inproc://zctx-pipe-%d", pipe.hashCode()));
        } else {
            return null;
        }

        // Connect child pipe to our pipe
View Full Code Here


        Socket inrouter = context.createSocket(ZMQ.ROUTER);

        router.setSendBufferSize(sendBufferSize);
        router.setEncoder(PersistEncoder.class);

        inrouter.bind(workerBind);

        for (int i = 0; i < numWorkers; i++) {
            String id = String.valueOf(i);
            ZPReaderWorker worker = new ZPReaderWorker(context, workerBind, id);
            worker.start();
View Full Code Here

        if (decoder)
            router.setDecoder(PersistDecoder.class);
        inrouter.setRouterMandatory(true);

        inrouter.bind(workerBind);

        for (int i = 0; i < numWorkers; i++) {
            String id = String.valueOf(i);
            ZPWriterWorker worker = new ZPWriterWorker(context, workerBind, id, decoder);
            worker.start();
View Full Code Here

    public void testError() throws Exception
    {

        Context ctx = ZMQ.context(1);
        Socket router = ctx.socket(ZMQ.ROUTER);
        router.bind("tcp://127.0.0.1:6001");
        router.setEncoder(Persistence.PersistEncoder.class);

        Socket dealer = ctx.socket(ZMQ.DEALER);
        dealer.setIdentity("A".getBytes());
        dealer.connect("tcp://127.0.0.1:6001");
View Full Code Here

    public void testResponse() throws Exception
    {

        Context ctx = ZMQ.context(1);
        Socket router = ctx.socket(ZMQ.ROUTER);
        router.bind("tcp://127.0.0.1:6002");
        router.setEncoder(Persistence.PersistEncoder.class);

        Socket dealer = ctx.socket(ZMQ.DEALER);
        dealer.setIdentity("A".getBytes());
        dealer.connect("tcp://127.0.0.1:6002");
View Full Code Here

        raf.close();
        ch.close();

        Context ctx = ZMQ.context(1);
        Socket router = ctx.socket(ZMQ.ROUTER);
        router.bind("tcp://127.0.0.1:6003");
        router.setEncoder(Persistence.PersistEncoder.class);

        Socket dealer = ctx.socket(ZMQ.DEALER);
        dealer.setIdentity("A".getBytes());
        dealer.connect("tcp://127.0.0.1:6003");
View Full Code Here

    public static void main (String[] args) {

        Context context = ZMQ.context(1);

        Socket clients = context.socket(ZMQ.ROUTER);
        clients.bind ("tcp://*:5555");

        Socket workers = context.socket(ZMQ.DEALER);
        workers.bind ("inproc://workers");

        for(int thread_nbr = 0; thread_nbr < 5; thread_nbr++) {
View Full Code Here

        Socket clients = context.socket(ZMQ.ROUTER);
        clients.bind ("tcp://*:5555");

        Socket workers = context.socket(ZMQ.DEALER);
        workers.bind ("inproc://workers");

        for(int thread_nbr = 0; thread_nbr < 5; thread_nbr++) {
            Thread worker = new Worker (context);
            worker.start();
        }
View Full Code Here

    {
        Random rand = new Random(System.nanoTime());

        Context context = ZMQ.context(1);
        Socket server = context.socket(ZMQ.REP);
        server.bind("tcp://*:5555");

        int cycles = 0;
        while (true) {
            String request = server.recvStr();
            cycles++;
View Full Code Here

            Socket frontend = ctx.createSocket(ZMQ.ROUTER);
            Socket backend = ctx.createSocket(ZMQ.ROUTER);
            frontend.setHWM (-1);
            backend.setHWM (-1);
            frontend.bind("tcp://*:5555");
            backend.bind("tcp://*:5556");

            while (!Thread.currentThread().isInterrupted()) {
                ZMQ.Poller items = new ZMQ.Poller(2);
                items.register(frontend, ZMQ.Poller.POLLIN);
                items.register(backend, ZMQ.Poller.POLLIN);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.