Home > Back-end >  Is there a library to work with this files in golang?
Is there a library to work with this files in golang?

Time:09-17

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?

CodePudding user response:

"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 ?).

  •  Tags:  
  • go
  • Related