-1

I was looking for information about .sock files and what is the unix: at the beginning of this type of file. For example in the nginx configuration files you can find this:

 fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;

And according to what I found on the internet they are called unix pipes, if I'm wrong please correct me, now that I've explained what I mean. Is there a library in golang to deal with this kind of files? I've been searching the internet and found very little information about it. Or is it possible to handle this kind of files in golang? It would be a good idea?

DFG
  • 31
  • 1
  • 13
  • You can use `net` package, this is the [example](https://stackoverflow.com/questions/2886719/unix-sockets-in-go) – Rahmat Fathoni Sep 15 '22 at 23:30
  • A Unix domain socket is different than a named pipe. https://en.wikipedia.org/wiki/Unix_domain_socket – JimB Sep 15 '22 at 23:59

1 Answers1

1

"unix domain socket" is not a file format, it is a construct handled by your system.

You interact with them much like you would interact with a tcp socket :

  • a server can listen on it (using net.Listen("unix", ...)),
  • a client can connect to it (using net.Dial("unix", ...)),
  • and then both can exchange messages using Read/Write.

See this question for a basic example of how to use them.

The format of the messages exchanged over this socket is hinted at by the fastcgi_pass part of your config line : fastcgi is a network protocol (wikipedia link) which describes how requests and responses should be exchanged.


Look for a golang library for "fastcgi server" or "fastcgi client" (I couldn't make out what side you are looking for from your question, I guess it would be a client ?).

LeGEC
  • 46,477
  • 5
  • 57
  • 104
  • Thank you very much, you have answered many of my questions in one answer, thank you very much. – DFG Sep 16 '22 at 17:05