What are socket files?

Sockets are a special file type, similar to TCP/IP sockets, providing inter-process networking protected by the file system's access control.

For example, when you open a listening socket in one terminal with netcat:

nc -lU socket.sock

then send data from another terminal by:

echo mytext | nc -U socket.sock

mytext appears on the first terminal.

By default nc stops listening after an End-of-File character.


A unix domain socket is a bidirectional pipe similar to a TCP/IP socket. A server listens for and accepts connections from clients, and then can communicate with the client on the newly accepted connection. What is special about unix domain sockets is that instead of having an IP address and port number, they have a file name as their address. This allows other applications that know nothing about networking to be told to open the file and read or write and the data is sent to the server instead of to the disk.

Tags:

Sockets

Tmux