On Thu, 25 Jun 2015 15:56:04 +0000 freeman via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote:
> 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? instead of: string socket_name = "\0/var/run/ptmd.socket"; try: string socket_name = "/var/run/ptmd.socket"; works for me