[erlang-questions] Unix Domain Sockets in v19

Raimo Niskanen <>
Tue Oct 18 10:22:50 CEST 2016


On Tue, Oct 18, 2016 at 09:59:46AM +0300, Taras Shapovalov wrote:
> Thank you, guys, for the comments.
> 
> I am still staggelling with gen_tcp. It is clear how to use gen_udp for
> this purpose, but not clear what to do with gen_tcp.
> 
> [ ~]$ erl
> Erlang/OTP 19 [erts-8.1] [source] [64-bit] [smp:4:4] [async-threads:10]
> [hipe] [kernel-poll:false]
> 
> Eshell V8.1  (abort with ^G)
> 1> {ok, S1} = gen_tcp:connect({local, <<"/var/run/docker.sock">>}, 0,
> [local]).
> {ok,#Port<0.448>}
> 3> gen_tcp:send(S1, <<"http:/containers/json">>).
> ok
> 4> A = gen_tcp:recv(S1,0).
> {error,einval}

To use gen_tcp:recv/2,3 on a socket it has to be opened with option
{active,false}, otherwise you get the messages as process messages.

  http://erlang.org/doc/man/gen_tcp.html#recv-2
    :
    Receives a packet from a socket in passive mode. ...

and the description of process messages under

  http://erlang.org/doc/man/gen_tcp.html#connect-3

> 5>
> 
> I don't get how to receive an answer from TCP unix socket.
> Should I create one more socket (to listen it) and somehow link them?
> 
> I should pass all options through to gen_tcp, so it is not impossible that
> > it can handle the 'local' address family.  Give it a try!
> >
> 
> Would be nice to see it in httpc as well!
> 
> Best regards,
> 
> Taras

> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions


-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


More information about the erlang-questions mailing list