Loading...
Select Version
&pagelevel(5)&pagelevel
With the AF_UNIX address family, a name (address) comprises a path name. You use the sockaddr_un address structure for the AF_UNIX address family.
The sockaddr_un structure is declared as follows in the <sys/un.h> header file:
struct sockaddr_un { sa_family_t sun_family; /* address family */ char sun_path[108]; /* path name */ };
You can supply a variable server of type struct sockaddr_un with a name, e.g. using the following statements:
struct sockaddr_un server; ... server.sun_family = AF_UNIX; strcpy(server.sun_path, “/tmp/unix_socket“);
A pointer to the variable server can now be passed as the current parameter, e.g. with a bind() call, to bind the name to a socket:
bind(..., (struct sockaddr *)&server, ...); /* bind() call with type conversion */