Skip to content

Commit 042a49d

Browse files
committed
Allow binaries to be used in bind & connect
1 parent 0faa7c1 commit 042a49d

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

include/erlzmq.hrl

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
%% <i>For more information see
6363
%% <a href="http://api.zeromq.org/master:zmq_bind">zmq_bind</a> or
6464
%% <a href="http://api.zeromq.org/master:zmq_connect">zmq_connect</a></i>
65-
-type erlzmq_endpoint() :: string().
65+
-type erlzmq_endpoint() :: string() | binary().
6666

6767
%% Standard error atoms.
6868
-type errno() :: eperm | enoent | srch | eintr | eio | enxio | ebad |

src/erlzmq.erl

+8-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ socket(Context, Type, {active, false}) ->
138138
erlzmq_error().
139139
bind({I, Socket}, Endpoint)
140140
when is_integer(I), is_list(Endpoint) ->
141-
erlzmq_nif:bind(Socket, Endpoint).
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)).
142145

143146
%% @doc Connect a socket.
144147
%% <br />
@@ -151,7 +154,10 @@ bind({I, Socket}, Endpoint)
151154
erlzmq_error().
152155
connect({I, Socket}, Endpoint)
153156
when is_integer(I), is_list(Endpoint) ->
154-
erlzmq_nif:connect(Socket, Endpoint).
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)).
155161

156162
%% @equiv send(Socket, Msg, [])
157163
-spec send(erlzmq_socket(),

0 commit comments

Comments
 (0)