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.
-
I don't seem to have the U option with nc, I got an error U option not defined. Is
socket.sock
a file you created previously¿? Can you use tmux -S and use the socket file descriptor (tipicaly 3) from one of the ends of the socket to send data on that socket¿?– aDoNCommented Apr 12, 2018 at 14:45 -
-
In Linux End-of-File is a condition, not a character. Commented Aug 4, 2022 at 0:00
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.
-
3