user2973395
user2973395

Reputation: 37

UDP-protocol doesn't work in ZeroMQ. Which socket type should be used?

I tried to connect my PUB-client ( uses pyzmq version 19.0.0 ) with server via udp://:

context = zmq.Context()
socket = context.socket( zmq.PUB )
socket.connect( "udp://127.0.0.1:34567" )

but the code throws always an error: zmq.error.ZMQError: The protocol is not compatible with the socket type

I have tried all socket types, like: REQ, REP, PUB, SUB, PAIR, DEALER, ROUTER, PULL, PUSH

Do you know what's the problem?

Upvotes: 1

Views: 4930

Answers (2)

user3666197
user3666197

Reputation: 1

ZeroMQ does support both :
both the UDP:// and {PGM|EPGM}:// transport-classes

Examples of { PGM | EPGM } :

// 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( socket,           "epgm://eth0;239.192.1.1:5555" );
assert ( rc == 0 and "ASSERT FAILED: epgm://eth0;239.192.1.1:5555 ............. " );

// Connecting to the multicast address 239.192.1.1, port 5555,
// using the network interface with the address 192.168.1.1
// and the standard PGM protocol

rc = zmq_connect(socket,            "pgm://192.168.1.1;239.192.1.1:5555" );
assert ( rc == 0 and "ASSERT FAILED: pgm://192.168.1.1;239.192.1.1:5555 ........" );

The pgm:// and epgm:// transports can only be used with the ZMQ_PUB and ZMQ_SUB socket types.


UDP:// transport can only be used with the ZMQ_RADIO and ZMQ_DISH socket types.

Examples of UDP .bind(), .connect()-s are analogous :

// Unicast - UDP port 5555 on all available interfaces
rc = zmq_bind( dish,                "udp://*:5555" );
assert ( rc == 0 and "ASSERT FAILED: udp://*:5555 ............. " );

// Unicast - UDP port 5555 on the local loop-back interface
rc = zmq_bind( dish,                "udp://127.0.0.1:5555" );
assert ( rc == 0 and "ASSERT FAILED: udp://127.0.0.1:5555 ............. " );

// Unicast - UDP port 5555 on interface eth1
rc = zmq_bind( dish,                "udp://eth1:5555" );
assert ( rc == 0 and "ASSERT FAILED: udp://eth1:5555 ............. " );

// Multicast - UDP port 5555 on a Multicast address
rc = zmq_bind( dish,                "udp://239.0.0.1:5555" );
assert ( rc == 0 and "ASSERT FAILED: udp://239.0.0.1:5555 ............. " );

// Same as above but joining only on interface eth0
rc = zmq_bind( dish,                "udp://eth0;239.0.0.1:5555" );
assert ( rc == 0 and "ASSERT FAILED: udp://eth0;239.0.0.1:5555 ............. " );

// Same as above using IPv6 multicast
rc = zmq_bind( dish,                "udp://eth0;[ff02::1]:5555" );
assert ( rc == 0 and "ASSERT FAILED: udp://eth0;[ff02::1]:5555 ............. " );

The Best Next Step :

Now review the scope and the state of the pyzmq-19.0.0 implementation of the native-API ( be it 4.3.2+ or older ).

Upvotes: 1

Nullman
Nullman

Reputation: 4279

zmq does not generally use udp sockets because they are unreliable, the only udp sockets are dish and radio but they are experimental, you can read more here
relevant quote:

UDP transport can only be used with the ZMQ_RADIO and ZMQ_DISH socket types.

Upvotes: 0

Related Questions