Abstract sockets (linux)
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jun 25 09:07:50 PDT 2015
On 6/25/15 11:56 AM, freeman 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 at runtime/phobos/std/socket.d(2674): Unable
> to connect socket: Connection refused
>
> Any pointers?
I believe there was a recently fixed bug regarding unix sockets. The
upcoming 2.068 may help, have you tried the beta?
http://downloads.dlang.org/pre-releases/2.x/2.068.0/
-Steve
More information about the Digitalmars-d-learn
mailing list