Search in sources :

Example 1 with IpcConnecter

use of zmq.io.net.ipc.IpcConnecter in project jeromq by zeromq.

the class SessionBase method startConnecting.

private void startConnecting(boolean wait) {
    assert (active);
    // Choose I/O thread to run connecter in. Given that we are already
    // running in an I/O thread, there must be at least one available.
    IOThread ioThread = chooseIoThread(options.affinity);
    assert (ioThread != null);
    // Create the connecter object.
    NetProtocol protocol = addr.protocol();
    if (protocol == null) {
        errno.set(ZError.EPROTONOSUPPORT);
        return;
    }
    switch(protocol) {
        case tcp:
            if (options.socksProxyAddress != null) {
                Address proxyAddress = new Address(NetProtocol.tcp, options.socksProxyAddress);
                SocksConnecter connecter = new SocksConnecter(ioThread, this, options, addr, proxyAddress, wait);
                launchChild(connecter);
            } else {
                TcpConnecter connecter = new TcpConnecter(ioThread, this, options, addr, wait);
                launchChild(connecter);
            }
            break;
        case ipc:
            {
                IpcConnecter connecter = new IpcConnecter(ioThread, this, options, addr, wait);
                launchChild(connecter);
            }
            break;
        case tipc:
            {
                TipcConnecter connecter = new TipcConnecter(ioThread, this, options, addr, wait);
                launchChild(connecter);
            }
            break;
        case pgm:
        case epgm:
            {
                assert (options.type == ZMQ.ZMQ_PUB || options.type == ZMQ.ZMQ_XPUB || options.type == ZMQ.ZMQ_SUB || options.type == ZMQ.ZMQ_XSUB);
                // For EPGM transport with UDP encapsulation of PGM is used.
                boolean udpEncapsulation = protocol == NetProtocol.epgm;
                // exists with PGM anyway.
                if (options.type == ZMQ.ZMQ_PUB || options.type == ZMQ.ZMQ_XPUB) {
                    // PGM sender.
                    PgmSender pgmSender = new PgmSender(ioThread, options);
                    boolean rc = pgmSender.init(udpEncapsulation, addr);
                    assert (rc);
                    sendAttach(this, pgmSender);
                } else {
                    // PGM receiver.
                    PgmReceiver pgmReceiver = new PgmReceiver(ioThread, options);
                    boolean rc = pgmReceiver.init(udpEncapsulation, addr);
                    assert (rc);
                    sendAttach(this, pgmReceiver);
                }
            }
            break;
        case norm:
            {
                // exists with NORM anyway.
                if (options.type == ZMQ.ZMQ_PUB || options.type == ZMQ.ZMQ_XPUB) {
                    // NORM sender.
                    NormEngine normSender = new NormEngine(ioThread, options);
                    boolean rc = normSender.init(addr, true, false);
                    assert (rc);
                    sendAttach(this, normSender);
                } else {
                    // NORM receiver.
                    NormEngine normReceiver = new NormEngine(ioThread, options);
                    boolean rc = normReceiver.init(addr, false, true);
                    assert (rc);
                    sendAttach(this, normReceiver);
                }
            }
            break;
        default:
            assert (false);
            break;
    }
}
Also used : IpcConnecter(zmq.io.net.ipc.IpcConnecter) SocksConnecter(zmq.io.net.tcp.SocksConnecter) Address(zmq.io.net.Address) TipcConnecter(zmq.io.net.tipc.TipcConnecter) PgmReceiver(zmq.io.net.pgm.PgmReceiver) NormEngine(zmq.io.net.norm.NormEngine) NetProtocol(zmq.io.net.NetProtocol) PgmSender(zmq.io.net.pgm.PgmSender) TcpConnecter(zmq.io.net.tcp.TcpConnecter)

Aggregations

Address (zmq.io.net.Address)1 NetProtocol (zmq.io.net.NetProtocol)1 IpcConnecter (zmq.io.net.ipc.IpcConnecter)1 NormEngine (zmq.io.net.norm.NormEngine)1 PgmReceiver (zmq.io.net.pgm.PgmReceiver)1 PgmSender (zmq.io.net.pgm.PgmSender)1 SocksConnecter (zmq.io.net.tcp.SocksConnecter)1 TcpConnecter (zmq.io.net.tcp.TcpConnecter)1 TipcConnecter (zmq.io.net.tipc.TipcConnecter)1