Erlang – spawnlink

Erlang spawnlink

In this guide, we will discuss Erlang Spawnlink. This is used to create a new process link on a node.

Syntax

spawn(Node,Function)

Parameters

  • Node − The node on which the function needs to be spawned.
  • Function − The function which needs to be spawned.

Return Value

This method returns a process id.

For example

-module(helloworld). 
-export([start/0]). 

start() -> 
   spawn_link(node(),fun() -> server("Hello") end). 

server(Message) ->
   io:fwrite("~p",[Message]).

Output

When we run the above program, we will get the following result.

“Hello”

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply