是否有内置功能在氮框架中获得同行IP地址?如果没有,是否有一种方法可以获取同行的IP地址,该地址正在要求氮化应用程序

有帮助吗?

解决方案

您可以使用远程对等地址使用 wf_platform:get_peername/0.

@spec wf_platform:get_peername() -> {ok, {Address, Port}} | {error, posix()}
    Address = {N1,N2,N3,N4} | {K1,K2,K3,K4,K5,K6,K7,K8}
    Port = int()

其他提示

从氮2开始,这样做的功能是 wf:peer_ip/0. 。目前似乎没有出现在任何文档中,但几乎做同样的事情 wf_platform:get_peername() 曾经。

wf:peer_ip/0 -> {A, B, C, D} | {A, B, C, D, E, F, G, H} 
%% example output: {127, 0, 0, 1}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top