【发布时间】:2018-12-13 20:10:00
【问题描述】:
我看到gen_udp 支持 Unix 套接字,this example 显示在 Erlang 中创建了一个 using one。
我想向现有的 Unix 套接字发送消息(通过其 JSON IPC 接口控制mpv)。我看到有 a self-answered question on the Erlang mailing list 关于这个,但答案对我来说没有意义,因为 Sock2 是在没有先前分配的情况下使用的。
我在gen_udp 文档中看到了这个选项:
{fd, integer() >= 0}
If a socket has somehow been opened without using gen_udp,
use this option to pass the file descriptor for it.
但是当我尝试使用file:open/2 将套接字作为文件打开时,我得到{error,eopnotsupp}。
如何向现有的 Unix 套接字发送消息?
【问题讨论】:
-
如果你得到
Sock2这样的邮件列表示例:{ok, Sock2} = gen_udp:open(0, [local]).
标签: erlang unix-socket