1ZMQ_TCP(7)                        0MQ Manual                        ZMQ_TCP(7)
2
3
4

NAME

6       zmq_tcp - 0MQ unicast transport using TCP
7

SYNOPSIS

9       TCP is an ubiquitous, reliable, unicast transport. When connecting
10       distributed applications over a network with 0MQ, using the TCP
11       transport will likely be your first choice.
12

ADDRESSING

14       A 0MQ endpoint is a string consisting of a transport:// followed by an
15       address. The transport specifies the underlying protocol to use. The
16       address specifies the transport-specific address to connect to.
17
18       For the TCP transport, the transport is tcp, and the meaning of the
19       address part is defined below.
20
21   Assigning a local address to a socket
22       When assigning a local address to a socket using zmq_bind() with the
23       tcp transport, the endpoint shall be interpreted as an interface
24       followed by a colon and the TCP port number to use.
25
26       An interface may be specified by either of the following:
27
28       •   The wild-card *, meaning all available interfaces.
29
30       •   The primary IPv4 or IPv6 address assigned to the interface, in its
31           numeric representation.
32
33       •   The non-portable interface name as defined by the operating system.
34
35       The TCP port number may be specified by:
36
37       •   A numeric value, usually above 1024 on POSIX systems.
38
39       •   The wild-card *, meaning a system-assigned ephemeral port.
40
41       When using ephemeral ports, the caller should retrieve the actual
42       assigned port using the ZMQ_LAST_ENDPOINT socket option. See
43       zmq_getsockopt(3) for details.
44
45   Unbinding wild-card address from a socket
46       When wild-card * endpoint was used in zmq_bind(), the caller should use
47       real endpoint obtained from the ZMQ_LAST_ENDPOINT socket option to
48       unbind this endpoint from a socket using zmq_unbind().
49
50   Connecting a socket
51       When connecting a socket to a peer address using zmq_connect() with the
52       tcp transport, the endpoint shall be interpreted as a peer address
53       followed by a colon and the TCP port number to use. You can optionally
54       specify a source_endpoint which will be used as the source address for
55       your connection; tcp://source_endpoint;'endpoint', see the interface
56       description above for details.
57
58       A peer address may be specified by either of the following:
59
60       •   The DNS name of the peer.
61
62       •   The IPv4 or IPv6 address of the peer, in its numeric
63           representation.
64
65       Note: A description of the ZeroMQ Message Transport Protocol (ZMTP)
66       which is used by the TCP transport can be found at
67       http://rfc.zeromq.org/spec:15
68

HWM

70       For the TCP transport, the high water mark (HWM) mechanism works in
71       conjunction with the TCP socket buffers handled at OS level. Depending
72       on the OS and several other factors the size of such TCP buffers will
73       be different. Moreover TCP buffers provided by the OS will accomodate a
74       varying number of messages depending on the size of messages (unlike
75       ZMQ HWM settings the TCP socket buffers are measured in bytes and not
76       messages).
77
78       This may result in apparently inexplicable behaviors: e.g., you may
79       expect that setting ZMQ_SNDHWM to 100 on a socket using TCP transport
80       will have the effect of blocking the transmission of the 101-th message
81       if the receiver is slow. This is very unlikely when using TCP transport
82       since OS TCP buffers will typically provide enough buffering to allow
83       you sending much more than 100 messages.
84
85       Of course if the receiver is slow, transmitting on a TCP ZMQ socket
86       will eventually trigger the "mute state" of the socket; simply don’t
87       rely on the exact HWM value.
88
89       Obviously the same considerations apply for the receive HWM (see
90       ZMQ_RCVHWM).
91

EXAMPLES

93       Assigning a local address to a socket.
94
95           //  TCP port 5555 on all available interfaces
96           rc = zmq_bind(socket, "tcp://*:5555");
97           assert (rc == 0);
98           //  TCP port 5555 on the local loop-back interface on all platforms
99           rc = zmq_bind(socket, "tcp://127.0.0.1:5555");
100           assert (rc == 0);
101           //  TCP port 5555 on the first Ethernet network interface on Linux
102           rc = zmq_bind(socket, "tcp://eth0:5555");
103           assert (rc == 0);
104
105       Connecting a socket.
106
107           //  Connecting using an IP address
108           rc = zmq_connect(socket, "tcp://192.168.1.1:5555");
109           assert (rc == 0);
110           //  Connecting using a DNS name
111           rc = zmq_connect(socket, "tcp://server1:5555");
112           assert (rc == 0);
113           //  Connecting using a DNS name and bind to eth1
114           rc = zmq_connect(socket, "tcp://eth1:0;server1:5555");
115           assert (rc == 0);
116           //  Connecting using a IP address and bind to an IP address
117           rc = zmq_connect(socket, "tcp://192.168.1.17:5555;192.168.1.1:5555");
118           assert (rc == 0);
119
120

SEE ALSO

122       zmq_bind(3) zmq_connect(3) zmq_pgm(7) zmq_ipc(7) zmq_inproc(7)
123       zmq_vmci(7) zmq(7)
124

AUTHORS

126       This page was written by the 0MQ community. To make a change please
127       read the 0MQ Contribution Policy at
128       http://www.zeromq.org/docs:contributing.
129
130
131
1320MQ 4.3.4                         07/23/2021                        ZMQ_TCP(7)
Impressum