AF_UNIX address family

This address family provides interprocess communications on the same system that uses the socket APIs. The address is really a path name to an entry in the file system.

You can create sockets in the root directory or any open file system but file systems such as QSYS or QDOC. The program must bind an AF_UNIX, SOCK_DGRAM socket to a name to receive any datagrams back. In addition, the program must explicitly remove the file system object with the unlink() API when the socket is closed.

Sockets with the address family AF_UNIX use the sockaddr_un address structure. This address structure changes if you use _XOPEN_SOURCE macro to implement BSD 4.4/ UNIX® 98 specifications. For the sockaddr_un address structure, these differences are summarized in the table:

Table 1. Differences between BSD 4.3 and BSD 4.4/ UNIX 98 for sockaddr_un address structure
BSD 4.3 sockaddr_un address structure BSD 4.4/ UNIX 98 sockaddr_un address structure
struct sockaddr_un {
     short    sun_family;
     char     sun_path[126];
}; 
struct sockaddr_un {
  uint8_t     sun_len;
  sa_family_t sun_family;
  char        sun_path[126];
};
Table 2. AF_UNIX address structure
Address structure field Definition
sun_len This field contains the length of the address for UNIX 98 specifications.
Note: The: sun_len field is only provided for BSD 4.4 compatibility. It is not necessary to use this field even when using BSD 4.4/ UNIX 98 compatibility. The field is ignored on input addresses.
sun_family This field contains the address family.
sun_path This field contains the path name to an entry in the file system.

For AF_UNIX address family, protocol specifications do not apply because protocol standards are not involved. The communications mechanism the two processes use is specific to the machine.

Related reference
Use AF_UNIX address family
AF_UNIX_CCSID address family
Related information
unlink()