I'm currently interesting in UNIX system.
For IPC(Interprocess Communication), UNIX uses a file named socket. I understand it works like server-client model, write-end and read-end uses socket file to communicate each other.
But I wonder how socket internally works. Each process designate a socket file(maybe with inode), then write and read on it? If it's true, can I watch raw data(or encapsulated data) if I'm watching this socket file?
One more, socket file has a format? For example, some application socket file like mysql.sock and docker.sock, they have their own format?
The proper name for unix sockets is Unix Domain Sockets, because they all reside within one computer. In a sense, sockets are a network that is entirely contained within the kernel; rather than using network interfaces to send data, that same data can be sent directly between programs
Despite creating files on disk, Unix sockets don’t actually write the data they send to the disk, as that would be far too slow. Instead, all the data is retained within kernel memory; the only point of the socket file is to maintain a reference to the socket, and to give it filesystem permissions to control access. For example, MySQL’s socket is usually at:
/var/lib/mysql/mysql.sock
This file doesn’t contain anything, and you shouldn’t modify it directly, except for the permissions where applicable. It’s just a name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With