Skip to content

Commit

Permalink
Allow binaries to be used in bind & connect
Browse files Browse the repository at this point in the history
  • Loading branch information
yrashk committed Mar 22, 2013
1 parent 0faa7c1 commit 042a49d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/erlzmq.hrl
Expand Up @@ -62,7 +62,7 @@
%% <i>For more information see
%% <a href="http://api.zeromq.org/master:zmq_bind">zmq_bind</a> or
%% <a href="http://api.zeromq.org/master:zmq_connect">zmq_connect</a></i>
-type erlzmq_endpoint() :: string().
-type erlzmq_endpoint() :: string() | binary().

%% Standard error atoms.
-type errno() :: eperm | enoent | srch | eintr | eio | enxio | ebad |
Expand Down
10 changes: 8 additions & 2 deletions src/erlzmq.erl
Expand Up @@ -138,7 +138,10 @@ socket(Context, Type, {active, false}) ->
erlzmq_error().
bind({I, Socket}, Endpoint)
when is_integer(I), is_list(Endpoint) ->
erlzmq_nif:bind(Socket, Endpoint).
erlzmq_nif:bind(Socket, Endpoint);
bind({I, Socket}, Endpoint)
when is_integer(I), is_binary(Endpoint) ->
bind({I, Socket}, binary_to_list(Endpoint)).

%% @doc Connect a socket.
%% <br />
Expand All @@ -151,7 +154,10 @@ bind({I, Socket}, Endpoint)
erlzmq_error().
connect({I, Socket}, Endpoint)
when is_integer(I), is_list(Endpoint) ->
erlzmq_nif:connect(Socket, Endpoint).
erlzmq_nif:connect(Socket, Endpoint);
connect({I, Socket}, Endpoint)
when is_integer(I), is_binary(Endpoint) ->
connect({I, Socket}, binary_to_list(Endpoint)).

%% @equiv send(Socket, Msg, [])
-spec send(erlzmq_socket(),
Expand Down

0 comments on commit 042a49d

Please sign in to comment.