use of zmq.io.net.norm.NormEngine 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;
}
}
Aggregations