DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

unix(7sock)


unix -- UNIX domain sockets

Synopsis

#include <sys/un.h>

Description

The UNIX® domain sockets facility provides for communication between processes running on the same UNIX system. Both SOCK_STREAM and SOCK_DGRAM types are supported. SOCK_STREAM provides for reliable communication. In most cases SOCK_DGRAM communication is also reliable because of the absence of a communication medium, however, use of SOCK_STREAM is encouraged.

UNIX domain addresses are pathnames. In other words, two processes can communicate by specifying the same pathname as their communications rendezvous point. The bind(3sock) function creates an entry in the filesystem for the pathname specified. If the pathname already exists, the bind call will fail.

Sockets in the UNIX domain protocol family use the following addressing structure:

   struct sockaddr_un {
       u_char    sun_len;
       u_char    sun_family;
       u_short   sun_path[108];
   };
To create or reference a UNIX domain socket, the sun_len field should be set to the length of the sockaddr_un structure or the length of the structure containing valid information (that is, up to and including the terminating zero byte in sun_path). The sun_family field should be set to AF_UNIX and the sun_path array should contain the path name of a rendezvous point.

Since there are no protocol numbers associated with UNIX domain sockets, the protocol argument to the socket call should be zero.

Closing a UNIX domain socket does not make the filesystem entry go away; an application should remove the entry using unlink(2) when finished.

References

bind(3sock), socket(3sock), unlink(2)

Notices

In UnixWare 7 the sockaddr structure has been modified to support variable length sockets. The net result of this modification is that the family member has been shortened to 8 bits and a new 8-bit member inserted before it called len. For more information on the new sockaddr structures, see also: inet(7tcp).
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004