msantos / procket

Erlang interface to low level socket operations
http://blog.listincomprehension.com/search/label/procket
BSD 3-Clause "New" or "Revised" License
283 stars 80 forks source link

Abstract UNIX socket issue #15

Closed jeanparpaillon closed 10 years ago

jeanparpaillon commented 10 years ago

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

msantos commented 10 years ago

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).
jeanparpaillon commented 10 years ago

Ok, got it. Thanks