What are socket files?

Recently, I started using tmux; I'm trying to use the pair programming feature in that software. During the process a socket file was created. My question is: what are socket files, how am I to open them on Ubuntu and how are they used?

2 Answers

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.

2

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.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like