Elaborating on the 2nd bullet, I understand that .sock files are for Inter-process communication. How can I 'communicate' with them? Let us say a sock file is designed to respond in a specific way (For ex: it takes the input 'time' and prints out the current time).
I prefer higher level programming languages (python) more than C/C++ . It'd also be better if someone can point me to some application (like nc maybe?) that I can use to communicate with .sock files in a quick and dirty way?
Thanks
A socket is a special file used for inter-process communication, which enables communication between two processes. In addition to sending data, processes can send file descriptors across a Unix domain socket connection using the sendmsg() and recvmsg() system calls.
To create a UNIX domain socket, use the socket function and specify AF_UNIX as the domain for the socket. The z/TPF system supports a maximum number of 16,383 active UNIX domain sockets at any time. After a UNIX domain socket is created, you must bind the socket to a unique file path by using the bind function.
Using -u along with -U tells netcat that it is a UNIX-domain datagram socket. Similarly, while using socat , use UNIX-CLIENT option. Using this option you can connect to both UNIX-domain stream and UNIX-domain datagram sockets.
The main difference between sockets and files is that the operating system binds file descriptors to a file or device when the open() call creates the file descriptor.
Sock files are socket files they are endpoints in communication pipes.
how to create socket files:
let uwsgi create them when interacting with servers(e.g. nginx) sudo uwsgi --ini /path/to/ini/file/ In the ini file you need to have passed a path to where you want to add the socket file .ini files will on unix sysytems live at /etc/uwsgi/sites/*.ini
create socket files using a high level language try python: python -c "import socket as s; sock = s.socket(s.AF_UNIX); sock.bind('/tmp/test.sock')"
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