[erlang-questions] Unix Domain Sockets in v19

Raimo Niskanen raimo+erlang-questions@REDACTED
Mon Oct 17 16:08:35 CEST 2016

On Sun, Oct 16, 2016 at 08:34:22PM +0300, Taras Shapovalov wrote:
> Hey guys,
> I would like to try the experimental feature of v19 -- unix sockets, but
> cannot get how it should be used. For example, if I send some request to
> docker with gen_udp, then I will get  {error,eprototype}:
> [taras@REDACTED ~]$ erl
> Erlang/OTP 19 [erts-8.1] [source] [64-bit] [smp:4:4] [async-threads:10]
> [kernel-poll:false]
> Eshell V8.1  (abort with ^G)
> 1> {ok, Sockout} = gen_udp:open(0, [{ifaddr, {local, "/tmp/testsockout"}}]).
> {ok,#Port<0.413>}
> 2> gen_udp:send(Sockout, {local, "/var/run/docker.sock"}, 0,
> "http:/containers/json").
> {error,eprototype}
> 3>
> The socket is available and accessable by the user. Say, this works fine:
> curl --unix-socket /var/run/docker.sock http:/containers/json
> Any idea what is going wrong there?

You send an UDP datagram to a TCP socket.
Other than that your code looks just fine...

 find /usr/include -type f | xargs fgrep EPROTOTYPE
 /usr/include/asm-generic/errno.h:#define	EPROTOTYPE	91	/* Protocol wrong type for socket */

> I will appreciate if someone points me to any documentation (I know the
> final description of the feature is not ready for now, but maybe there is
> some draft already exists?).
> Also do you know if httpc module supports the unix sockets since 19.0? If
> yes, how to do the same with httpc?

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!

> Best regards,
> Taras


/ Raimo Niskanen, Erlang/OTP, Ericsson AB

More information about the erlang-questions mailing list