Next: Local Namespace Details, Up: Local Namespace
In the local namespace socket addresses are file names. You can specify any file name you want as the address of the socket, but you must have write permission on the directory containing it. It's common to put these files in the /tmp directory.
One peculiarity of the local namespace is that the name is only used when opening the connection; once open the address is not meaningful and may not exist.
Another peculiarity is that you cannot connect to such a socket from another machine–not even if the other machine shares the file system which contains the name of the socket. You can see the socket in a directory listing, but connecting to it never succeeds. Some programs take advantage of this, such as by asking the client to send its own process ID, and using the process IDs to distinguish between clients. However, we recommend you not use this method in protocols you design, as we might someday permit connections from other machines that mount the same file systems. Instead, send each new client an identifying number if you want it to have one.
After you close a socket in the local namespace, you should delete the
file name from the file system. Use unlink
or remove
to
do this; see Deleting Files.
The local namespace supports just one protocol for any communication
style; it is protocol number 0
.