Abstract sockets (linux)

freeman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 25 12:46:46 PDT 2015


On Thursday, 25 June 2015 at 18:50:29 UTC, Daniel Kozak wrote:
>> Any pointers?
>
> instead of:
> string socket_name = "\0/var/run/ptmd.socket";
> try:
> string socket_name = "/var/run/ptmd.socket";
> works for me

It is the null character that makes it an abstract socket (see 
man unix).  There is no file /var/run/ptmd.socket, as what 
follows the null character is just a name:
     $ ls -al /var/run/ptmd.socket
     ls: cannot access /var/run/ptmd.socket: No such file or 
directory

Here is what happens when I remove the null:
     
std.socket.SocketOSException at runtime/phobos/std/socket.d(2674): 
Unable to connect socket: No such file or directory


More information about the Digitalmars-d-learn mailing list