Zeromq interface function: ZMQ-0MQ Lightweight message transfer kernel

Source: Internet
Author: User
Tags creative commons attribution

ZMQ (7) 0MQ manual-0mq/3.2.5

Name

ZMQ–ØMQ Lightweight message transfer kernel

Synopsis

#include <znq.h>  cc–lzmq [libraries]

Description

The ØMQ lightweight message transfer kernel is a link library that extends from the standard socket interface, which is typically provided by some specialized transfer intermediate devices. ØMQ provides one-step messaging, multimodal messaging, message filtering (subscription), and a collection of seamless access to a variety of transport protocols.

This document presents the concept of ØMQ and describes how ØMQ abstracts the standard sockets and provides a reference manual for the functions provided by the ØMQ library.

Context

Before using any of the ØMQ Library functions, you must create a ØMQ context. This context must be destroyed (deleted) at the end of the application . The function is used to manipulate the context.

Create a new context

Zmq_ctx_new (3)

Properties of the action context

Zmq_ctx_set (3) zmq_ctx_get (3)

Delete a context

Zmq_ctx_destroy (3)

Monitor A context

Zmq_ctx_set_monitor (3)

The following deprecated functions can also be used to create and delete context

Initialize a context

Zmq_init (3)

end a context

Zmq_term (3)

Thread Safety (Threads safe)

The ØMQ context is thread-safe and can be shared as arbitrarily as possible by multiple threads, without the need to add request locks on the caller's side.

A single socket is not thread-safe unless the memory of a socket is moved from one thread to the next . In fact, this means that the application can create a socketin a thread with the function Zmq_soc ket ()and then pass it to a new creation thread as part of the thread's initialization. For example, you can pass a struct as a parameter to the function pthread_create ().

Multiple contexts

There can be multiple context coexistence in an application . This allows the application to manipulate the context directly while also using any number of other libraries or modules, which are themselves used as thread-safe ØMQ as mentioned above .

Messages

A ØMQ message is a discrete message unit that travels between applications or between different modules in the same program. ØMQ the message has no internal structure, and the In Ømq's own perspective, messages are considered opaque binary data.

The following function is used to manipulate the message:

Initialize a message

Zmq_msg_init (3) zmq_msg_init_size (3) Zmq_msg_init _data (3)

sending and receiving messages

Zmq_msg_send (3) ZMQ_MSG_RECV (3)

Release Message

Zmq_msg_close (3)

Get Message

Zmq_msg_data (3) zmq_msg_size (3) Zmq_msg_mor E (3)

Setting message Properties

Zmq_msg_get (3) Zmq_msg_set (3)

Message Processing

Zmq_msg_copy (3) zmq_msg_move (3)

Sockets

ØMQ sockets uses an abstract asynchronous message queue, which is implemented through an accurate socket-type-based semantic approach. The Query zmq_socket (3) function can see which socket types are available for use.

The following functions are provided to manipulate the socket :

Create a socket

Zmq_socket (3)

close a socket

Zmq_close (3)

manipulating the socket Property

Zmq_getsockopt (3) zmq_setsockopt (3)

Specify the socket message Flow

Zmq_bind (3) zmq_connect (3)

send and receive messages

Zmq_msg_send (3) ZMQ_MSG_RECV (3) zmq_send (3) ZMQ_RECV (3)

Input/output multiplexing (multiple input / output)

The ØMQ provides a mechanism for the ØMQ socktes and Standard socktes to enable the application to perform multiple input / output processes. This mechanism maps to a standard poll () system call, which is described in more detail in zmq_poll (3) .

Transports

A ØMQ socket can use a variety of different underlying transport mechanisms. Each transmission mechanism is suitable for specific use purposes, and each has its own advantages and disadvantages.

Single transport uses TCP

ZMQ_TCP (7)

Reliable multi-channel broadcast transmission using PGM

ZMQ_PGM (7)

Local transport within the process

ZMQ_IPC (7)

Local transport within the process (inside the thread)

Zmq_inproc (7)

Proxies

ØMQ provides a proxy for creating fan-in and fan-out topologies. An agent links a frontend socket to a backend socketand transparently transmits all messages between two Sockte. The agent can obtain all the transmitted data of a third party transparently. You can use the proxy in your application using zmq_proxy (3) .

Error Handling

The ØMQ library function uses standard provisions in POSIX systems to obtain error information. Typically, this means that the ØMQ library function returns NULL(if the pointer type is returned) or returns a negative value (if the int type is returned ). The true error value is stored in the errno variable.

In non-POSIX systems, developers may experience The current value of the errno variable. the zmq_errno () function is used to solve such a problem. For more details, please see the Zmq_errno (3) function.

Zmq_strerror () function is used to ØMQ The specified error value is converted to a string type of information, see the function for more details Zmq_strerror (3) .

Miscellaneous

Here are some of the remaining functions:

Returns the version number of the ØMQ library

Zmq_version (3)

Language Bindings

The ØMQ Cuiti provides an interface that can be invoked for various languages. The excuses described in this document can be used for the C program Ape. The intent of this article is that ØMQ users of other languages should be able to contact their own language versions through this article.

language versions (C + +,Python,PHP,Ruby,Java etc.) was ØMQ other members of the community, you can ØMQ Find them on the website.

Authors

THISØMQ manual page was written by Martin Sustrik < [email protected] >, Martinlucina < [email protected] > , and Pieter Hintjens < [email protected] >.

Resources

Main website:http://www.zeromq.org/

Report bugs to THEØMQ Development mailing list:< [email protected]>

Copying

Free use of this software isgranted under the terms of the GNU Lesser general public License

(LGPL). For details see the Files COPYING and COPYING. LESSER included with THEØMQ distribution.

Website Design and content is copyright (c) 2007-2012 Imatix Corporation. ContactUs for Professional Support. Site content licensed under the Creative Commons attribution-share alike 3.0 License. ØMQ is copyright (c) Copyright (c) 2007-2012 Imatix Corporation and Contributors. ØMQ is free software licensed under the LGPL. ØMQ, ZeroMQ, and 0MQ is trade marks of Imatix Corporation. Terms of Use-privacy Policy

Translator: The Storm

Mail: [Email protected]

Zeromq interface function: ZMQ-0MQ Lightweight message transfer kernel

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.