Key differences to conventional sockets
Conventional sockets present a synchronous interface to either connection-oriented reliable byte streams (SOCK_STREAM), or connection-less unreliable datagrams (SOCK_DGRAM).
ØMQ sockets present an abstraction of an asynchronous message queue, with the exact queueing semantics depending on the socket type in use. Where conventional sockets transfer streams of bytes or discrete datagrams, ØMQ sockets transfer discrete messages.
Conventional sockets allow only strict one-to-one (two peers), many-to-one (many clients, one server), or in some cases one-to-many (multicast) relationships. With the exception of ZMQ_PAIR, ØMQ sockets may be connected to multiple endpoints usingzmq_connect(), while simultaneously accepting incoming connections from multiple endpoints bound to the socket using zmq_bind(), thus allowing many-to-many relationships.
4 ØMQ Socket types
Request-reply pattern
- ZMQ_REQ
- ZMQ_REP
- ZMQ_DEALER
- ZMQ_ROUTER
Publish-subscribe pattern
- ZMQ_PUB
- ZMQ_SUB
Pipeline pattern (Push–pull)
沒有留言:
張貼留言