toraritte
toraritte

Reputation: 8273

Is net_kernel:connect/1 deprecated?

I started learning Erlang from Erlang Programming (O'Reilly, 2009) and the net_kernel:connect/1 function is used in the examples to show how to connect to other nodes.

I tried to look this function up in the official documentation but net_kernel:connect/1 is not even mentioned and most of the newer sources (eg. Learn You Some Erlang) use net_kernel:connect_node/1 exclusively.

So far I've come across a couple of commands that were explicitly tagged as deprecated in the doc but there was always an advice on what to use instead. Is connect/1 kept only for backwards compatibility?

I also traced back both functions and they both are translated to net_kernel:request({connect, normal, Node}) at one point.

Upvotes: 4

Views: 1011

Answers (1)

Steve Vinoski
Steve Vinoski

Reputation: 20014

The net_kernel:connect/1 function isn't deprecated, but for applications you should use the net_kernel:connect_node/1 function. In the Erlang/OTP source code, the net_kernel:connect/1 function is called only by Erlang BIFs related to Distributed Erlang. Though as you've observed both it and net_kernel:connect_node/1 eventually result in calls to net_kernel:request/1, the net_kernel:connect/1 function first performs checks related to Distributed Erlang.

Upvotes: 3

Related Questions