I am having trouble using abstract sockets on Linux.

Here is sample python code that works, which works:
    ptm_sockname = "\0/var/run/ptmd.socket"
    sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    sock.connect(ptm_sockname)
    sock.setblocking(1)
    sock.sendall('get-status detail')

Similar code in D, which does not work:
    string socket_name = "\0/var/run/ptmd.socket";
    auto address = new UnixAddress(socket_name);
    auto sock = new Socket(AddressFamily.UNIX, SocketType.STREAM);
    scope(exit) sock.close();
    sock.blocking = true;
    sock.connect(address);
    sock.send("get-status detail");

This is the equivalent with socat, which works:
$ echo "get-status detail" | socat - ABSTRACT-CLIENT:/var/run/ptmd.socket

My test D program exits on connect:
std.socket.SocketOSException@runtime/phobos/std/socket.d(2674): Unable to connect socket: Connection refused

Any pointers?

Reply via email to