[erlang-questions] How to transform a classical code in worker process ?

Gamoto gamoto@REDACTED
Wed May 13 17:16:08 CEST 2009


Hi All,

I have this "classical skeleton" code:

init(Port)->
   case gen_tcp:listen(Port, ...) of
     {ok,LSocket} -> 
		spawn(server_accept(LSocket))
     ...

server_accept(LSocket)->
    case gen_tcp:accept(LSocket) of
      {ok,SSocket} ->
		 spawn(connection(SSocket)),
         spawn(server_accept(LSocket));
      ...

connection(SSocket) ->
	case gen_tcp:recv(SSocket,0) of
	  {ok, Data} -> 
		Data_handling(Data),
        connection(SSocket);
      ...
    
How to transform this code into worker processes in order to have a better control
of the server_accept processes and connection processes ?
Please don't write "check the link blabla", most examples are difficult to understand.
Explain me rather the demarch by using pseudo code.
Thank's
John





More information about the erlang-questions mailing list