Zeromq interface function: Zmq_connect-Create an external connection from a socket

Source: Internet
Author: User
Tags creative commons attribution

ZeroMQ Official Address: Http://api.zeromq.org/4-0:zmq_connect

Zmq_connect (3) ØMQ Manual-ømq/3.2.5

Name

Zmq_connect- Create an external connection from a socket (outgoing connection)

Synopsis

int zmq_connect (voidconstChar *endpoint);

Description

Zmq_connect The () function connects the socket to the node endpoint and then begins accepting incoming connection requests on that node.

Endpoint is a string that contains a protocol :// immediately following a Address address. The Protocol has the following protocol designation. address Specifies the addresses to be bound for transfer.

The ZMQ provides the following communication protocols:

Tcp

Use TCP for reliable unicast protocols. See also press zmq_tcp (7)

Ipc

Local inter-process information transfer, see Press ZMQ_IPC (7)

InProc

Local in-process (inter-thread) messaging, see Zmq_inproc (7)

PGM, EPGM

Reliable multicast transmission using PGM, see ZMQ_PGM (7)

In addition to Zmq_pair, all ZMQ socket types support one-to-many and multi-pair transports. This precise multiplexing relies on the socket type defined in zmq_socket (3) .

For most transport and socket types, the connection is not executed immediately, but is required for ZMQ. In this way, a successful call to Zmq_connect () does not mean that the connection is actually established. Therefore, for most transmission and socket types, is the server advanced binding or client Advanced connection request is no different. The first exception is when to use inproc://transport: You must execute Zmq_bind () before calling Zmq_connect (). Then there is the Zmq_pair type of socket, which does not automatically reconnect to the node address.
After the Zmq_connect () function, the socket enters the normal ready state. In contrast to Zmq_bind (), Zmq_bind () is muted, in which case the socket blocks or discards the message, which, of course, depends on the type of socket specified in zmq_socket (3) .

Return value

Zmq_connect () returns 0 when execution succeeds. Other conditions return-1, and set errno to the following values.

Errors

EINVAL

The provided node is not available.

Eprotonosupport

The transport protocol used by the request is not supported.

Enocompatproto

The transport protocol used by the request is incompatible with the type of socket.

Eterm

The ZMQ context connected to the given socket is terminated.

Enotsock

The provided socket is not available.

Emthread

There are no available I/O threads that can be used to complete this task.

Example

1 /*Create a zmq_sub socket*/2 3 void*socket =zmq_socket (context, zmq_sub);4 5 assert (socket);6 7 /*Connect it to a in-process transport with the address ' my_publisher8 9 int rc = zmq_connect (socket, "inproc://my_publisher");Ten  One assert (rc = = 0); A  - / * Connect it to the host server001, Port 5555 using a TCP transport*/ -  therc = Zmq_connect (socket,"tcp://server001:5555"); ASSERT (rc = =0);

See Also

Zmq_bind (3) Zmq_socket (3) ZMQ (7)

Authors

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

<[email protected]> and Martin Lucina <[email protected]sk>.

WEB site design and content is copyright (c) 2007-2012 Imatix Corporation. Contact us 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 are trademarks of Imatix Corporation. Terms of Use-privacy

Policy

Translation: The Storm

Mail: [Email protected]

Zeromq interface function: Zmq_connect-Create an external connection from a socket

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.