linux – What are files with the "sock" extension for?


Some applications, such as PHP-FPM and MYSQL, usually use a file with the .sock extension in their configurations.

I always see this on Linux operating systems.



As far as I understand it is related to socket connection.

I was wondering what the purpose of this sock file is.

My other curiosity is: Using it, is it not necessary to open a port for socket connections? Would the sock file itself be the connection?


For external connections yes, but this has to be done by the software that owns the socket.

Sockets are communication points on the same or different computers to exchange data. They are supported by Unix, Linux, BSDs, Windows, Mac others. It's faster and more efficient communication than TCP/IP.

In addition to sending data, processes can send file descriptors over a Unix domain socket connection using the sendmsg() and recvmsg() system calls . This allows the sending processes to grant the receiving process access to a file descriptor to which the receiving process does not otherwise have access.

Scroll to Top