Skip to content
This repository
Newer
Older
100644 478 lines (443 sloc) 15.214 kb
fa6cb337 »
2011-03-24 Add active receive with eunit tests. NIF code cleanup.
1 %% -*- coding:utf-8;Mode:erlang;tab-width:4;c-basic-offset:4;indent-tabs-mode:nil -*-
2 %% ex: set softtabstop=4 tabstop=4 shiftwidth=4 expandtab fileencoding=utf-8:
3 %%
91b4e62b »
2011-03-27 Make the NIF more robust. Guard non-reentrant ZeroMQ sockets. Provide…
4 %% Copyright (c) 2011 Yurii Rashkovskii, Evax Software and Michael Truog
7dcd68fa »
2012-03-08 migrate from the 2.1 api to 3.1 api for zmq
5 %%
fa6cb337 »
2011-03-24 Add active receive with eunit tests. NIF code cleanup.
6 %% Permission is hereby granted, free of charge, to any person obtaining a copy
7 %% of this software and associated documentation files (the "Software"), to deal
8 %% in the Software without restriction, including without limitation the rights
9 %% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 %% copies of the Software, and to permit persons to whom the Software is
11 %% furnished to do so, subject to the following conditions:
7dcd68fa »
2012-03-08 migrate from the 2.1 api to 3.1 api for zmq
12 %%
fa6cb337 »
2011-03-24 Add active receive with eunit tests. NIF code cleanup.
13 %% The above copyright notice and this permission notice shall be included in
14 %% all copies or substantial portions of the Software.
7dcd68fa »
2012-03-08 migrate from the 2.1 api to 3.1 api for zmq
15 %%
fa6cb337 »
2011-03-24 Add active receive with eunit tests. NIF code cleanup.
16 %% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 %% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 %% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 %% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 %% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 %% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 %% THE SOFTWARE.
23
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
24 -module(erlzmq).
25 %% @headerfile "erlzmq.hrl"
26 -include_lib("erlzmq.hrl").
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
27 -export([context/0,
28 context/1,
29 socket/2,
30 bind/2,
31 connect/2,
32 send/2,
33 send/3,
7dcd68fa »
2012-03-08 migrate from the 2.1 api to 3.1 api for zmq
34 sendmsg/2,
35 sendmsg/3,
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
36 recv/1,
37 recv/2,
7dcd68fa »
2012-03-08 migrate from the 2.1 api to 3.1 api for zmq
38 recvmsg/1,
39 recvmsg/2,
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
40 setsockopt/3,
41 getsockopt/2,
42 close/1,
91b4e62b »
2011-03-27 Make the NIF more robust. Guard non-reentrant ZeroMQ sockets. Provide…
43 close/2,
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
44 term/1,
c1604bae »
2011-06-09 erlzmq:version/0
45 term/2,
46 version/0]).
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
47 -export_type([erlzmq_socket/0, erlzmq_context/0]).
48
49 %% @equiv context(1)
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
50 -spec context() ->
51 {ok, erlzmq_context()} |
52 erlzmq_error().
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
53 context() ->
54 context(1).
55
56 %% @doc Create a new erlzmq context with the specified number of io threads.
57 %% <br />
58 %% If the context can be created an 'ok' tuple containing an
59 %% {@type erlzmq_context()} handle to the created context is returned;
60 %% if not, it returns an 'error' tuple with an {@type erlzmq_type_error()}
61 %% describing the error.
62 %% <br />
63 %% The context must be later cleaned up calling {@link erlzmq:term/1. term/1}
64 %% <br />
65 %% <i>For more information see
66 %% <a href="http://api.zeromq.org/master:zmq-init">zmq_init</a></i>
67 %% @end
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
68 -spec context(Threads :: pos_integer()) ->
69 {ok, erlzmq_context()} |
70 erlzmq_error().
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
71 context(Threads) when is_integer(Threads) ->
72 erlzmq_nif:context(Threads).
73
74
75 %% @doc Create a socket.
76 %% <br />
77 %% This functions creates a socket of the given
26220ce0 »
2011-03-30 Minor doc update
78 %% {@link erlzmq_socket_type(). type}, optionally setting it to active mode,
79 %% and associates it with the given {@link erlzmq_context(). context}.
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
80 %% <br />
81 %% If the socket can be created an 'ok' tuple containing a
82 %% {@type erlzmq_socket()} handle to the created socket is returned;
dad60bab »
2011-03-30 Document the performance implications of socket modes
83 %% if not, it returns an {@type erlzmq_error()} describing the error.
84 %% <br />
85 %% In line with Erlang's socket paradigm, a socket can be either active or
86 %% passive. Passive sockets tend to have lower latency and have a higher
87 %% throughput for small message sizes. Active sockets on the contrary give
88 %% the highest throughput for messages above 32k. A benchmarking tool is
26220ce0 »
2011-03-30 Minor doc update
89 %% included in the source distribution.<br />
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
90 %% <i>For more information see
91 %% <a href="http://api.zeromq.org/master:zmq_socket">zmq_socket</a>.</i>
92 %% @end
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
93 -spec socket(Context :: erlzmq_context(),
94 Type :: erlzmq_socket_type() |
95 list(erlzmq_socket_type() |
a45c2ad2 »
2013-02-08 Add {active_pid, pid()} option to socket/2, which implies {active, tr…
96 {active, boolean()} |
97 {active_pid, pid()})) ->
32a7039e »
2011-03-31 Simplify use of erlzmq_socket() type
98 {ok, erlzmq_socket()} |
99 erlzmq_error().
fa6cb337 »
2011-03-24 Add active receive with eunit tests. NIF code cleanup.
100 socket(Context, Type) when is_atom(Type) ->
101 socket(Context, [Type]);
20f0fe82 »
2012-02-17 Fix Dialyzer warnings
102 socket(Context, [H | T]) when is_atom(H) ->
103 case T of
104 [] ->
78f5d0b8 »
2011-03-29 Make passive mode default.
105 % active is false by default
106 % (to avoid latency on small messages (messages < 32KB))
20f0fe82 »
2012-02-17 Fix Dialyzer warnings
107 socket(Context, H, {active, false});
108 [Active] ->
109 socket(Context, H, Active)
110 end;
111 socket(Context, [H | [Type]]) when is_tuple(H) ->
112 socket(Context, Type, H).
113
114 -spec socket(Context :: erlzmq_context(),
115 Type :: erlzmq_socket_type(),
a45c2ad2 »
2013-02-08 Add {active_pid, pid()} option to socket/2, which implies {active, tr…
116 {active, boolean()} | {active_pid, pid()}) ->
20f0fe82 »
2012-02-17 Fix Dialyzer warnings
117 {ok, erlzmq_socket()} |
118 erlzmq_error().
119 socket(Context, Type, {active, true}) ->
120 true = (Type =/= pub) and (Type =/= push) and (Type =/= xpub),
a45c2ad2 »
2013-02-08 Add {active_pid, pid()} option to socket/2, which implies {active, tr…
121 erlzmq_nif:socket(Context, socket_type(Type), 1, self());
122 socket(Context, Type, {active_pid, Pid})
123 when is_pid(Pid), node(Pid) =:= node() ->
124 true = (Type =/= pub) and (Type =/= push) and (Type =/= xpub),
125 erlzmq_nif:socket(Context, socket_type(Type), 1, Pid);
20f0fe82 »
2012-02-17 Fix Dialyzer warnings
126 socket(Context, Type, {active, false}) ->
a45c2ad2 »
2013-02-08 Add {active_pid, pid()} option to socket/2, which implies {active, tr…
127 erlzmq_nif:socket(Context, socket_type(Type), 0, self()).
7dcd68fa »
2012-03-08 migrate from the 2.1 api to 3.1 api for zmq
128
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
129
130 %% @doc Accept connections on a socket.
131 %% <br />
132 %% <i>For more information see
133 %% <a href="http://api.zeromq.org/master:zmq_bind">zmq_bind</a>.</i>
134 %% @end
32a7039e »
2011-03-31 Simplify use of erlzmq_socket() type
135 -spec bind(Socket :: erlzmq_socket(),
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
136 Endpoint :: erlzmq_endpoint()) ->
137 ok |
138 erlzmq_error().
139 bind({I, Socket}, Endpoint)
140 when is_integer(I), is_list(Endpoint) ->
042a49de »
2013-03-22 Allow binaries to be used in bind & connect
141 erlzmq_nif:bind(Socket, Endpoint);
142 bind({I, Socket}, Endpoint)
143 when is_integer(I), is_binary(Endpoint) ->
144 bind({I, Socket}, binary_to_list(Endpoint)).
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
145
146 %% @doc Connect a socket.
147 %% <br />
148 %% <i>For more information see
149 %% <a href="http://api.zeromq.org/master:zmq_connect">zmq_connect</a>.</i>
150 %% @end
32a7039e »
2011-03-31 Simplify use of erlzmq_socket() type
151 -spec connect(Socket :: erlzmq_socket(),
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
152 Endpoint :: erlzmq_endpoint()) ->
153 ok |
154 erlzmq_error().
155 connect({I, Socket}, Endpoint)
156 when is_integer(I), is_list(Endpoint) ->
042a49de »
2013-03-22 Allow binaries to be used in bind & connect
157 erlzmq_nif:connect(Socket, Endpoint);
158 connect({I, Socket}, Endpoint)
159 when is_integer(I), is_binary(Endpoint) ->
160 connect({I, Socket}, binary_to_list(Endpoint)).
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
161
162 %% @equiv send(Socket, Msg, [])
20f0fe82 »
2012-02-17 Fix Dialyzer warnings
163 -spec send(erlzmq_socket(),
164 Binary :: binary()) ->
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
165 ok |
166 erlzmq_error().
32a7039e »
2011-03-31 Simplify use of erlzmq_socket() type
167 send(Socket, Binary) when is_binary(Binary) ->
168 send(Socket, Binary, []).
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
169
170 %% @doc Send a message on a socket.
171 %% <br />
172 %% <i>For more information see
173 %% <a href="http://api.zeromq.org/master:zmq_send">zmq_send</a>.</i>
174 %% @end
20f0fe82 »
2012-02-17 Fix Dialyzer warnings
175 -spec send(erlzmq_socket(),
176 Binary :: binary(),
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
177 Flags :: erlzmq_send_recv_flags()) ->
178 ok |
179 erlzmq_error().
180 send({I, Socket}, Binary, Flags)
181 when is_integer(I), is_binary(Binary), is_list(Flags) ->
c4598252 »
2011-03-18 Defer to polling thread on blocking send
182 case erlzmq_nif:send(Socket, Binary, sendrecv_flags(Flags)) of
183 Ref when is_reference(Ref) ->
184 receive
185 {Ref, ok} ->
186 ok;
fa6cb337 »
2011-03-24 Add active receive with eunit tests. NIF code cleanup.
187 {Ref, {error, _} = Error} ->
188 Error
7dcd68fa »
2012-03-08 migrate from the 2.1 api to 3.1 api for zmq
189 after case erlzmq_nif:getsockopt(Socket,?'ZMQ_SNDTIMEO') of
190 {ok, -1} ->
191 infinity;
192 {ok, Else} ->
193 Else
194 end ->
195 {error, eagain}
c4598252 »
2011-03-18 Defer to polling thread on blocking send
196 end;
197 Result ->
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
198 Result
c4598252 »
2011-03-18 Defer to polling thread on blocking send
199 end.
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
200
7dcd68fa »
2012-03-08 migrate from the 2.1 api to 3.1 api for zmq
201 %% @equiv send(Socket, Msg, [])
202 %% @doc This function exists for zeromq api compatibility and doesn't
203 %% actually provide any different functionality then what you get with
204 %% the {@link erlzmq:send/2} function. In fact this function just
205 %% calls that function. So there is a slight bit of additional
206 %% overhead as well.
207 -spec sendmsg(erlzmq_socket(),
208 Binary :: binary()) ->
209 ok |
210 erlzmq_error().
211 sendmsg(Socket, Binary) when is_binary(Binary) ->
212 send(Socket, Binary, []).
213
214 %% @equiv send(Socket, Msg, Flags)
215 %% @doc This function exists for zeromq api compatibility and doesn't
216 %% actually provide any different functionality then what you get with
217 %% the {@link erlzmq:send/3} function. In fact this function just
218 %% calls that function. So there is a slight bit of additional
219 %% overhead as well.
220 -spec sendmsg(erlzmq_socket(),
221 Binary :: binary(),
222 Flags :: erlzmq_send_recv_flags()) ->
223 ok |
224 erlzmq_error().
225 sendmsg(Socket, Binary, Flags) ->
226 send(Socket, Binary, Flags).
227
228
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
229 %% @equiv recv(Socket, 0)
32a7039e »
2011-03-31 Simplify use of erlzmq_socket() type
230 -spec recv(Socket :: erlzmq_socket()) ->
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
231 {ok, erlzmq_data()} |
232 erlzmq_error().
32a7039e »
2011-03-31 Simplify use of erlzmq_socket() type
233 recv(Socket) ->
234 recv(Socket, []).
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
235
236 %% @doc Receive a message from a socket.
237 %% <br />
238 %% <i>For more information see
239 %% <a href="http://api.zeromq.org/master:zmq_recv">zmq_recv</a>.</i>
240 %% @end
32a7039e »
2011-03-31 Simplify use of erlzmq_socket() type
241 -spec recv(Socket :: erlzmq_socket(),
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
242 Flags :: erlzmq_send_recv_flags()) ->
243 {ok, erlzmq_data()} |
7dcd68fa »
2012-03-08 migrate from the 2.1 api to 3.1 api for zmq
244 erlzmq_error().
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
245 recv({I, Socket}, Flags)
246 when is_integer(I), is_list(Flags) ->
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
247 case erlzmq_nif:recv(Socket, sendrecv_flags(Flags)) of
248 Ref when is_reference(Ref) ->
249 receive
2f3ea86e »
2013-03-07 Always provide a normal error result for very improbable receive erro…
250 {Ref, {error, _} = Error} ->
251 Error;
6cf222c2 »
2011-06-10 Changing the recv() back to a 2-tuple response
252 {Ref, Result} ->
253 {ok, Result}
7dcd68fa »
2012-03-08 migrate from the 2.1 api to 3.1 api for zmq
254 after case erlzmq_nif:getsockopt(Socket,?'ZMQ_RCVTIMEO') of
255 {ok, -1} ->
256 infinity;
257 {ok, Else} ->
258 Else
259 end ->
260 {error, eagain}
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
261 end;
262 Result ->
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
263 Result
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
264 end.
265
7dcd68fa »
2012-03-08 migrate from the 2.1 api to 3.1 api for zmq
266 %% @equiv recv(Socket, 0)
267 %% @doc This function exists for zeromq api compatibility and doesn't
268 %% actually provide any different functionality then what you get with
269 %% the {@link erlzmq:recv/3} function. In fact this function just
270 %% calls that function. So there is a slight bit of additional
271 %% overhead as well.
272 -spec recvmsg(Socket :: erlzmq_socket()) ->
273 {ok, erlzmq_data()} |
274 erlzmq_error().
275 recvmsg(Socket) ->
276 recv(Socket, []).
277
278 %% @equiv recv(Socket, Flags)
279 %% @doc This function exists for zeromq api compatibility and doesn't
280 %% actually provide any different functionality then what you get with
281 %% the {@link erlzmq:recv/3} function. In fact this function just
282 %% calls that function. So there is a slight bit of additional
283 %% overhead as well.
284 -spec recvmsg(Socket :: erlzmq_socket(),
285 Flags :: erlzmq_send_recv_flags()) ->
286 {ok, erlzmq_data()} |
287 erlzmq_error().
288 recvmsg(Socket, Flags) ->
289 recv(Socket, Flags).
290
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
291 %% @doc Set an {@link erlzmq_sockopt(). option} associated with a socket.
292 %% <br />
293 %% <i>For more information see
294 %% <a href="http://api.zeromq.org/master:zmq_setsockopt">zmq_setsockopt</a>.</i>
295 %% @end
20f0fe82 »
2012-02-17 Fix Dialyzer warnings
296 -spec setsockopt(erlzmq_socket(),
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
297 Name :: erlzmq_sockopt(),
20f0fe82 »
2012-02-17 Fix Dialyzer warnings
298 erlzmq_sockopt_value() | binary()) ->
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
299 ok |
300 erlzmq_error().
32a7039e »
2011-03-31 Simplify use of erlzmq_socket() type
301 setsockopt(Socket, Name, Value) when is_list(Value) ->
302 setsockopt(Socket, Name, erlang:list_to_binary(Value));
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
303 setsockopt({I, Socket}, Name, Value) when is_integer(I), is_atom(Name) ->
304 erlzmq_nif:setsockopt(Socket, option_name(Name), Value).
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
305
306 %% @doc Get an {@link erlzmq_sockopt(). option} associated with a socket.
307 %% <br />
308 %% <i>For more information see
309 %% <a href="http://api.zeromq.org/master:zmq_getsockopt">zmq_getsockopt</a>.</i>
310 %% @end
32a7039e »
2011-03-31 Simplify use of erlzmq_socket() type
311 -spec getsockopt(Socket :: erlzmq_socket(),
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
312 Name :: erlzmq_sockopt()) ->
313 {ok, erlzmq_sockopt_value()} |
314 erlzmq_error().
315 getsockopt({I, Socket}, Name) when is_integer(I), is_atom(Name) ->
316 erlzmq_nif:getsockopt(Socket, option_name(Name)).
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
317
91b4e62b »
2011-03-27 Make the NIF more robust. Guard non-reentrant ZeroMQ sockets. Provide…
318 %% @equiv close(Socket, infinity)
32a7039e »
2011-03-31 Simplify use of erlzmq_socket() type
319 -spec close(Socket :: erlzmq_socket()) ->
91b4e62b »
2011-03-27 Make the NIF more robust. Guard non-reentrant ZeroMQ sockets. Provide…
320 ok |
321 erlzmq_error().
32a7039e »
2011-03-31 Simplify use of erlzmq_socket() type
322 close(Socket) ->
323 close(Socket, infinity).
91b4e62b »
2011-03-27 Make the NIF more robust. Guard non-reentrant ZeroMQ sockets. Provide…
324
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
325 %% @doc Close the given socket.
326 %% <br />
327 %% <i>For more information see
328 %% <a href="http://api.zeromq.org/master:zmq_close">zmq_close</a>.</i>
329 %% @end
32a7039e »
2011-03-31 Simplify use of erlzmq_socket() type
330 -spec close(Socket :: erlzmq_socket(),
91b4e62b »
2011-03-27 Make the NIF more robust. Guard non-reentrant ZeroMQ sockets. Provide…
331 Timeout :: timeout()) ->
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
332 ok |
333 erlzmq_error().
91b4e62b »
2011-03-27 Make the NIF more robust. Guard non-reentrant ZeroMQ sockets. Provide…
334 close({I, Socket}, Timeout) when is_integer(I) ->
335 case erlzmq_nif:close(Socket) of
336 Ref when is_reference(Ref) ->
337 receive
338 {Ref, Result} ->
339 Result
340 after
341 Timeout ->
342 {error, {timeout, Ref}}
343 end;
344 Result ->
345 Result
346 end.
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
347
348 %% @equiv term(Context, infinity)
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
349 -spec term(Context :: erlzmq_context()) ->
350 ok |
351 erlzmq_error().
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
352 term(Context) ->
353 term(Context, infinity).
354
355 %% @doc Terminate the given context waiting up to Timeout ms.
356 %% <br />
357 %% This function should be called after all sockets associated with
358 %% the given context have been closed.<br />
359 %% If not it will block the given Timeout amount of time.
360 %% <i>For more information see
361 %% <a href="http://api.zeromq.org/master:zmq_term">zmq_term</a>.</i>
362 %% @end
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
363 -spec term(Context :: erlzmq_context(),
364 Timeout :: timeout()) ->
365 ok |
366 erlzmq_error() |
367 {error, {timeout, reference()}}.
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
368
369 term(Context, Timeout) ->
370 case erlzmq_nif:term(Context) of
371 Ref when is_reference(Ref) ->
372 receive
373 {Ref, Result} ->
374 Result
91b4e62b »
2011-03-27 Make the NIF more robust. Guard non-reentrant ZeroMQ sockets. Provide…
375 after
376 Timeout ->
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
377 {error, {timeout, Ref}}
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
378 end;
379 Result ->
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
380 Result
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
381 end.
382
c1604bae »
2011-06-09 erlzmq:version/0
383 %% @doc Returns the 0MQ library version.
384 %% @end
385 -spec version() -> {integer(), integer(), integer()}.
386
387 version() -> erlzmq_nif:version().
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
388
389 %% Private
390
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
391 -spec socket_type(Type :: erlzmq_socket_type()) ->
392 integer().
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
393
394 socket_type(pair) ->
395 ?'ZMQ_PAIR';
396 socket_type(pub) ->
397 ?'ZMQ_PUB';
398 socket_type(sub) ->
399 ?'ZMQ_SUB';
400 socket_type(req) ->
401 ?'ZMQ_REQ';
402 socket_type(rep) ->
403 ?'ZMQ_REP';
e7464db9 »
2011-06-08 dealer and router socket types
404 socket_type(dealer) ->
405 ?'ZMQ_DEALER';
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
406 socket_type(xreq) ->
407 ?'ZMQ_XREQ';
e7464db9 »
2011-06-08 dealer and router socket types
408 socket_type(router) ->
409 ?'ZMQ_ROUTER';
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
410 socket_type(xrep) ->
411 ?'ZMQ_XREP';
412 socket_type(pull) ->
413 ?'ZMQ_PULL';
414 socket_type(push) ->
415 ?'ZMQ_PUSH';
416 socket_type(xpub) ->
417 ?'ZMQ_XPUB';
418 socket_type(xsub) ->
419 ?'ZMQ_XSUB'.
420
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
421 -spec sendrecv_flags(Flags :: erlzmq_send_recv_flags()) ->
422 integer().
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
423
424 sendrecv_flags([]) ->
425 0;
7dcd68fa »
2012-03-08 migrate from the 2.1 api to 3.1 api for zmq
426 sendrecv_flags([dontwait|Rest]) ->
427 ?'ZMQ_DONTWAIT' bor sendrecv_flags(Rest);
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
428 sendrecv_flags([sndmore|Rest]) ->
429 ?'ZMQ_SNDMORE' bor sendrecv_flags(Rest).
430
9ed06d96 »
2011-03-25 Provide a 2tuple/index envelope for matching on erlzmq sockets return…
431 -spec option_name(Name :: erlzmq_sockopt()) ->
432 integer().
baa83453 »
2011-03-09 Renamed ezmq to erlzmq2
433
434 option_name(affinity) ->
435 ?'ZMQ_AFFINITY';
436 option_name(identity) ->
437 ?'ZMQ_IDENTITY';
438 option_name(subscribe) ->
439 ?'ZMQ_SUBSCRIBE';
440 option_name(unsubscribe) ->
441 ?'ZMQ_UNSUBSCRIBE';
442 option_name(rate) ->
443 ?'ZMQ_RATE';
444 option_name(recovery_ivl) ->
445 ?'ZMQ_RECOVERY_IVL';
446 option_name(sndbuf) ->
447 ?'ZMQ_SNDBUF';
448 option_name(rcvbuf) ->
449 ?'ZMQ_RCVBUF';
450 option_name(rcvmore) ->
451 ?'ZMQ_RCVMORE';
452 option_name(fd) ->
453 ?'ZMQ_FD';
454 option_name(events) ->
455 ?'ZMQ_EVENTS';
456 option_name(linger) ->
457 ?'ZMQ_LINGER';
458 option_name(reconnect_ivl) ->
459 ?'ZMQ_RECONNECT_IVL';
460 option_name(backlog) ->
461 ?'ZMQ_BACKLOG';
462 option_name(reconnect_ivl_max) ->
7dcd68fa »
2012-03-08 migrate from the 2.1 api to 3.1 api for zmq
463 ?'ZMQ_RECONNECT_IVL_MAX';
464 option_name(maxmsgsize) ->
465 ?'ZMQ_MAXMSGSIZE';
466 option_name(sndhwm) ->
467 ?'ZMQ_SNDHWM';
468 option_name(rcvhwm) ->
469 ?'ZMQ_RCVHWM';
470 option_name(multicast_hops) ->
471 ?'ZMQ_MULTICAST_HOPS';
472 option_name(rcvtimeo) ->
473 ?'ZMQ_RCVTIMEO';
474 option_name(sndtimeo) ->
475 ?'ZMQ_SNDTIMEO';
476 option_name(ipv4only) ->
477 ?'ZMQ_IPV4ONLY'.
Something went wrong with that request. Please try again.