msantos / procket

Erlang interface to low level socket operations

Home Page:http://blog.listincomprehension.com/search/label/procket

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Abstract UNIX socket issue

jeanparpaillon opened this issue · comments

Hi,
I am using unix domain socket in the code below:
https://github.com/lizenn/erlang-dbus/blob/master/src/dbus_transport_unix.erl

When connecting to an abstract UNIX domain socket, I get econnrefused. UNIX domain socket with real path are ok.

I've traced procket.c and the sockaddr_un structure thinks ok (with leading '\0' before path).

Any clue to check where it may come from ?

Regards,
Jean

For an abstract socket, everything after the '\0' is considered to be part of the path. So, unlike a normal unix socket with a path on the file system, the sockaddr struct shouldn't be padded:

{ok, Socket} = procket:socket(1,1,0),
Name = <<"/tmp/foo">>,
Sun = <<1:16/native, 0, Name/binary>>,
procket:connect(Socket, Sun).

Ok, got it. Thanks