Go to the previous, next section.

Details of File Namespace

To create a socket in the file namespace, use the constant PF_FILE as the namespace argument to socket or socketpair. This constant is defined in `sys/socket.h'.

Macro: int PF_FILE

This designates the file namespace, in which socket addresses are file names, and its associated family of protocols.

Macro: int PF_UNIX

This is a synonym for PF_FILE, for compatibility's sake.

The structure for specifying socket names in the file namespace is defined in the header file `sys/un.h':

Data Type: struct sockaddr_un

This structure is used to specify file namespace socket addresses. It has the following members:

short int sun_family
This identifies the address family or format of the socket address. You should store the value AF_FILE to designate the file namespace. See section Socket Addresses.

char sun_path[108]
This is the file name to use.

Incomplete: Why is 108 a magic number? RMS suggests making this a zero-length array and tweaking the example following to use alloca to allocate an appropriate amount of storage based on the length of the filename.

You should compute the length parameter for a socket address in the file namespace as the sum of the size of the sun_family component and the string length (not the allocation size!) of the file name string.

Go to the previous, next section.