Re: How to check UID of process on the other side of local TCP/UDP connection

Filipe Varela wrote:

I'll clarify my question as i seem to have failed to make it clear.

My point is: Isn't it wrong to use the term unix sockets for local
domain sockets?

No. If you look at the PF_* AND AF_* macros in <sys/socket.h> (or
<bits/socket.h> in glibc-2), you will see something like:

#define PF_LOCAL 1 /* Local to host (pipes and file-domain). */
#define PF_UNIX PF_LOCAL /* Old BSD name for PF_LOCAL. */
#define PF_FILE PF_LOCAL /* Another non-standard name for PF_LOCAL. */


Note that all of these are equal. Historically, PF_UNIX (aka PF_LOCAL
or PF_FILE) have commonly been called "Unix-domain sockets". E.g. from
the Xserver(1) manpage:

The X server supports client connections via a platform-dependent sub-
set of the following transport types: TCPIP, Unix Domain sockets, DEC-
net, and several varieties of SVR4 local connections. See the DISPLAY
NAMES section of the X(7x) manual page to learn how to specify which
transport type clients should try to use.

In the context of the original email, most people seem to have
understood that the term "Unix sockets" was used in the sense of

This isn't a tecnical question or a failure to
understand what sockets are, what varieties exist and for what
purposes each can be used (and what goodies each type provides). It's
a failure to understand why the term unix sockets is used to
designate local domain sockets.

The PF_UNIX and AF_UNIX macros came first; the *_LOCAL and *_FILE
aliases came later, and are still less common, e.g. Microsoft's
winsock.h only defines PF_UNIX, not PF_LOCAL or PF_FILE (ditto for the
AF_* macros).

The point in using the tcp/udp example is that contrary to popular
designation, the sentence "doing tcp/udp is impossible with unix
sockets because unix sockets are local domain sockets" is false. Unix
sockets are the general class. While it's true that local domain
sokets do not use tcp/udp, it's false (and this is a conceptual stand
not an everyday unix jargon use) that unix sockets = local domain


local domain

And this is the view that i would like you to tell me is right or
wrong (i'm not standing by it, just asking what you consider it to be).

If you are referring to sockets in the sense of the "socket" API in
<sys/socket.h>, or in the sense of the S_ISSOCK() macro from
<sys/stat.h>, they would normally just be called "sockets", or
possibly "BSD sockets" or "Berkeley sockets".

On Linux, the documentation for this address/protocol family is in the
unix(7) manpage:

UNIX(7) Linux Programmer's Manual UNIX(7)

unix, PF_UNIX, AF_UNIX, PF_LOCAL, AF_LOCAL - Sockets for local inter-
process communication

#include <sys/socket.h>
#include <sys/un.h>

unix_socket = socket(PF_UNIX, type, 0);
error = socketpair(PF_UNIX, type, 0, int *sv);

There isn't a local(7) or file(7) manpage.

Google indicates ~247,000 results for AF_UNIX versus ~28,800 for
AF_LOCAL, and ~51,000 results for PF_UNIX versus 19,300 for PF_LOCAL.

The Wikipedia disambiguation page for "Sockets" at:


In computing:

* an end-point of a bi-directional communication link in the Berkeley sockets API
* Internet socket, an end-point in the IP networking protocol
* Unix domain socket, an end-point in local inter-process communication
* A networking utility similar to nc (netcat)

The page for the third one:


A Unix domain socket or IPC socket (inter-procedure call
socket) is a virtual socket, similar to an internet socket
that is used in POSIX operating systems for inter-process
communication. The correct standard POSIX term is POSIX Local
IPC Sockets.

These connections appear as a byte stream network connection
but go from the local computer to itself.

In addition to sending data, processes can send file
descriptors across a Unix domain socket connection using the
sendmsg() and recvmsg() system calls.

All in all, PF_UNIX/PF_LOCAL/PF_FILE sockets are still called
"Unix-domain" sockets far more often than "Local-domain" sockets.

Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>

Relevant Pages

  • Re: write() and send() or sendto() ?
    ... > and I believed sendcould only be used with connection oriented ... difference between connection-oriented or connectionless sockets here so ... (It would also be possible to use the native Win32 ... like writein Unix can write to any Unix file object descriptor.) ...
  • Re: C Sockets Newbie: Easy question
    ... If this is an exam question for a sockets course, ... either the file descriptor of the open file (which is a small number ... "Unix Network Programming" by Stevens. ...
  • Re: server socket weirdness
    ... It's a bug/feature in some versions of Tcl. ... I assume it would be using the unix branch, ... and handle the bind error by adding ... was removed for Win sockets, but it was still there for unix. ...
  • Re: open(2) and unix domain sockets
    ... >> might support for domain sockets 'cause trouble? ... > sockets act so much like files. ... Unix or two have shipped it. ...
  • Re: wait until appears in string
    ... > There are no sockets in Standard C, which is the sole topic discussed ... which reads lines from a file pointer. ... > In Unix you can finagle a socket into a file pointer using fdopen. ... > Win32 newsgroup. ...