erlang: UNIX domain socket support?

后端 未结 4 1225
忘掉有多难
忘掉有多难 2020-12-31 11:18

Is there a way to access UNIX domain sockets (e.g. /var/run/dbus/system_bus_socket ) directly from Erlang without resorting to a third-party driver?

4条回答
  •  梦毁少年i
    2020-12-31 12:15

    The nanomsg library supports Unix domain sockets, and the enm driver provides an Erlang language binding for nanomsg.

    For example, to open the response side of a request/response protocol and bind to a Unix domain socket address:

    Url = "ipc:///path/to/socket/file",
    {ok,Rep} = enm:rep([{bind,Url}]),
    

    Here, Rep is a nanomsg socket. It supports send and recv as well as all the usual Erlang {active, true | false | N} modes, etc. that regular Erlang TCP/SCTP/UDP sockets provide. For more details consult the enm github README.

提交回复
热议问题