Abstract sockets (linux)
freeman via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jun 25 08:56:04 PDT 2015
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?
More information about the Digitalmars-d-learn
mailing list