Search in sources :

Example 1 with ZObject

use of zmq.ZObject in project jeromq by zeromq.

the class SessionBase method zapConnect.

public int zapConnect() {
    assert (zapPipe == null);
    Ctx.Endpoint peer = findEndpoint("inproc://zeromq.zap.01");
    if (peer.socket == null) {
        errno.set(ZError.ECONNREFUSED);
        return ZError.ECONNREFUSED;
    }
    if (peer.options.type != ZMQ.ZMQ_REP && peer.options.type != ZMQ.ZMQ_ROUTER && peer.options.type != ZMQ.ZMQ_SERVER) {
        errno.set(ZError.ECONNREFUSED);
        return ZError.ECONNREFUSED;
    }
    // Create a bi-directional pipe that will connect
    // session with zap socket.
    ZObject[] parents = { this, peer.socket };
    int[] hwms = { 0, 0 };
    boolean[] conflates = { false, false };
    Pipe[] pipes = Pipe.pair(parents, hwms, conflates);
    // Attach local end of the pipe to this socket object.
    zapPipe = pipes[0];
    zapPipe.setNoDelay();
    zapPipe.setEventSink(this);
    sendBind(peer.socket, pipes[1], false);
    // Send empty identity if required by the peer.
    if (peer.options.recvIdentity) {
        Msg id = new Msg();
        id.setFlags(Msg.IDENTITY);
        zapPipe.write(id);
        zapPipe.flush();
    }
    return 0;
}
Also used : Msg(zmq.Msg) Ctx(zmq.Ctx) Pipe(zmq.pipe.Pipe) ZObject(zmq.ZObject)

Example 2 with ZObject

use of zmq.ZObject in project jeromq by zeromq.

the class MTrieTest method createPipe.

private Pipe createPipe() {
    ZObject object = new ZObject(null, 0) {
    };
    Pipe[] pair = Pipe.pair(new ZObject[] { object, object }, new int[2], new boolean[2]);
    return pair[0];
}
Also used : Pipe(zmq.pipe.Pipe) ZObject(zmq.ZObject)

Aggregations

ZObject (zmq.ZObject)2 Pipe (zmq.pipe.Pipe)2 Ctx (zmq.Ctx)1 Msg (zmq.Msg)1