summaryrefslogtreecommitdiff
path: root/man/man7/zmq_tcp.7
blob: aa3f56e31e40ddf8d73beb225e86169d52aad3b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
.TH zmq_tcp 7 "" "(c)2007-2010 iMatix Corporation" "0MQ User Manuals"
.SH NAME
TCP-based tranport for 0MQ
.SH SYNOPSIS

TCP is an ubiquitous unicast transport. When connecting distributed
applications, you will mostly use TCP transport.

.SH CONNECTION STRING

Connection string for TCP transport is "tcp://" followed by an IP adress,
colon and port number. IP address can be either its numeric representation,
a NIC name or a hostname (resolved by DNS):

.nf
    tcp://192.168.0.111:5555
    tcp://myserver001:80
    tcp://lo:32768
.fi

.SH WIRE FORMAT

A message consists of a message length followed by message data.
Size of message data MUST correspond to the message length.

For messages of 0 to 254 octets, the length is represented by single octet. 

For messages of 255 or more octets the length is represented by a single octet
%xFF followed by a 64-bit unsigned integer length in network byte order.

The protocol can be defined by this BNF grammar:

.nf
    frame   = length data
    length  = OCTET | escape 8*OCTET
    escape  = %xFF
    data    = *OCTET
.fi

Binary layout of a message (up to 254 bytes long):

.nf
0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Message size  |                Message body               ... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Message body ...
+-+-+-+-+-+-+- ...

Binary layout of a larger message:

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     0xff      |                Message size               ... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Message size                       ... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Message size |                Message body               ... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Message body ...
+-+-+-+-+-+-+-+ ...
.fi

.SH "SEE ALSO"

.BR zmq_udp (7)
.BR zmq_pgm (7)
.BR zmq_inproc (7)

.SH AUTHOR
Martin Sustrik <sustrik at 250bpm dot com>