有没有一个用于在golang中处理这些文件的库?

huangapple go评论82阅读模式
英文:

Is there a library to work with this files in golang?

问题

我正在寻找关于.sock文件以及这种类型文件开头的unix:的信息。例如,在nginx配置文件中,你可以找到这样的内容:

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

根据我在互联网上找到的信息,它们被称为unix管道,如果我错了,请纠正我,现在我已经解释了我的意思。在golang中是否有处理这种类型文件的库?我在互联网上搜索了很少的信息。或者在golang中处理这种类型文件是可能的吗?这是一个好主意吗?

英文:

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?

答案1

得分: 1

"unix domain socket"(https://en.wikipedia.org/wiki/Unix_domain_socket)不是一个文件格式,而是由您的系统处理的一种构造。

您可以像与TCP套接字交互一样与它们交互:

  • 服务器可以监听它(使用net.Listen("unix", ...)),
  • 客户端可以连接到它(使用net.Dial("unix", ...)),
  • 然后两者都可以使用Read/Write交换消息。

有关如何使用它们的基本示例,请参见此问题

通过此套接字交换的消息的格式由您配置行中的fastcgi_pass部分暗示:fastcgi是一种网络协议(维基百科链接),描述了请求和响应的交换方式。


寻找一个适用于"fastcgi server"或"fastcgi client"的Golang库(根据您的问题,我无法确定您是在寻找哪一方,我猜可能是客户端)。

英文:

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

huangapple
  • 本文由 发表于 2022年9月16日 07:07:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/73738251.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定