-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
138 lines (90 loc) · 4.05 KB
/
README
File metadata and controls
138 lines (90 loc) · 4.05 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
This is C++ binding for Crossroads I/O
======================================
Build and installation
----------------------
C++ binding consists of a single header file -- xs.hpp. No special build
steps are needed. To install, copy the file onto your include path.
License
-------
The project is licensed under MIT license. See xs.hpp for the exact wording.
Synopsis
--------
#include <xs.hpp>
Description
-----------
This manual page describes how the Crossroads C++ language binding maps to the
underlying Crossroads C library functions.
All constants defined by xs.h are also available to the C++ language
binding.
The following classes are provided in the 'xs' namespace:
Context
~~~~~~~
The 'context_t' class encapsulates functionality dealing with the
initialisation and termination of a Crossroads context.
context_t::context_t() maps to the xs_init() function.
context_t::~context_t() maps to the xs_term() function.
context_t::setctxopt () maps to xs_setctxopt() function.
Socket
~~~~~~
The 'socket_t' class encapsulates a Crossroads socket.
socket_t::socket_t() maps to the xs_socket() function.
socket_t::~socket_t() maps to xs_close() function.
socket_t::getsockopt() maps to the xs_getsockopt() function.
socket_t::setsockopt() maps to the xs_setsockopt() function.
socket_t::bind() maps to the xs_bind() function.
socket_t::connect() maps to the xs_connect() function.
socket_t::shutdown() maps to the xs_shutdown() function.
socket_t::send(const void *buf, size_t len, int flags = 0) maps to xs_send()
function.
socket_t::send(message_t &msg, int flags = 0) maps to xs_sendmsg() function.
The method returns true if message is successfully sent, false if it is not.
socket_t::recv(void *buf, size_t len, int flags = 0) maps to xs_recv() function.
socket_t::recv(message_t *msg, int flags = 0) maps to xs_recvmsg() function.
The method returns true if message is successfully received, false if it is not.
Message
~~~~~~~
The 'message_t' class encapsulates the xs_msg_t structure and
functions to construct, destruct and manipulate Crossroads messages.
message_t::message_t(void) maps to xs_msg_init() function.
message_t::message_t(size_t size) maps to xs_msg_init_size() function.
message_t::message_t(void *data, size_t size, free_fn *ffn, void *hint = NULL)
maps to xs_msg_init_data() function.
message_t::~message_t() maps to xs_msg_close() function.
message_t::data() maps to xs_msg_data() function.
message_t::size() maps to xs_msg_size() function.
message_t::copy (message_t *src) maps to the xs_msg_copy() function.
message_t::move (message_t *src) maps to the xs_msg_move() function.
message_t::rebuild(void) maps to xs_msg_close() and subsequent xs_msg_init().
message_t::rebuild(size_t size) maps to xs_msg_close() and subsequent
xs_msg_init_size().
message_t::rebuild(void *data, size_t size, free_fn *ffn, void *hint = NULL)
maps to xs_msg_close() and subsequent xs_msg_init_data().
message_t::getmsgopt() maps to xs_getmsgopt() function.
Input/output multiplexing
~~~~~~~~~~~~~~~~~~~~~~~~~
xs::poll() maps to xs_poll() function. To obtain a Crossroads socket handle
for use in a xs::pollitem_t structure, you should cast an instance of the
socket_t class to void*.
Error handling
--------------
All errors reported by the underlying Crossroads C library functions are
automatically converted to exceptions by the C++ language binding.
The 'xs::error_t' class is derived from the 'std::exception' class and uses the
xs_strerror() function to convert the error code to human-readable string.
Example
-------
xs::context_t ctx;
xs::socket_t s (ctx, XS_PUB);
s.connect ("tcp://192.168.0.115:5555");
xs::message_t msg (100);
memset (msg.data (), 0, 100);
s.send (msg);
Bug Reporting
-------------
To report a bug, send an email describing your problem to the Crossroads
mailing list (crossroads-dev@groups.crossroads.io). Prefix the subject of the
email by [BUG] to make bug reports easier to spot.
Mailing List
------------
Discussions about C++ language binding take place on the Crossroads
mailing list (crossroads-dev@groups.crossroads.io).