Q : What is it that I need to do to send data with UDP instead of TCP...?
A :
Well,
ZeroMQ has a way to use UDP-transport for Pragmatic General Multicast (PGM) protocol, be it either of ZeroMQ { pgm:// | epgm:// }
-transport-classes. Yet, caveats apply:
The pgm
transport implementation requires access to raw IP sockets. Additional privileges may be required on some operating systems for this operation. Applications not requiring direct interoperability with other PGM implementations are encouraged to use the epgm
transport instead which does not require any special privileges.
So, for the ZeroMQ classical PUB / SUB
-data-flows, one can setup something like this :
//
// Connecting to the multicast address 239.192.1.1, port 5555,
// using the first Ethernet network interface on Linux
// and the Encapsulated PGM protocol
//
rc = zmq_connect( aMulticastOverUDP_socket, "epgm://eth0;239.192.1.1:5555" );
assert (rc == 0 && "____ Well, something went wrong on epgm:// connect" );
In Python, that might sound like:
#----------------------------------------------------- start Context()-engine
aContext = zmq.Context( nIoTHREADs )
#----------------------------------------------------- start Socket()-instances
aUdpPUB = aContext.socket( zmq.PUB )
#----------------------------------------------------- start settings
aUdpPUB.setsockopt( zmq.LINGER, 0 )
aUdpPUB.setsockopt( zmq...., ... )
...
#----------------------------------------------------- start serving
aUdpPUB.bind( "epgm://eth0;239.192.1.1:5555" )
...
#----------------------------------------------------- start dismantling
aUdpPUB.close()
aContext.term()
For fine-tuning the E2E performance, one has to tweak related Context()
-instances' zmq_setsockopt()
-parameters, to squeeze the transport on max