<p>I have a problem of how to get the return value of a function when</p><p>spawn_link(Fun) ->pid() is used. </p><p>Im going to use above function in following manner.</p><p>init([]) -></p><p>ChildPid = erlang:spawn_link(?MODULE, connect_to_server, [Ip,Port, ConId, self(),State]).<br>
</p><p>connect_to_server(Ip, Port, ConId, ParentPid,State) -><br>             case Result= gen_tcp:connect(Ip, Port, <br>                                  [binary, {packet, 0}]) of <br>            {ok, Socket} -><br>                                       io:format("Socket Received:~w~n",[Socket]),                    <br>
                                       ok =(catch gen_server:call(g_srv, {add_conn, self(), ConId, Socket})),<br>                                       NewState = State#state{socket= Socket};<br>            {error, Reason} ->       <br>                                          io:format("connection error host Ip:~w Port: ~w ~w ~n", [Ip,Port,Reason]) ,  <br>
                                       connect_to_server(Ip, Port, ConId, ParentPid,State)                      <br>     end.           <br>     <br> I want to get the return value of connect_to_server function. How can I do that.</p><p></p><p>Regards </p>
<p>Thilani<br><br></p>