[erlang-questions] Good Explanation of gen_tcp:listen ({active, true}) ?

Stéphane Wirtel <>
Tue Dec 23 20:59:53 CET 2014


Hi all,

In an example from a friend, I see this code.

For the listener
```
{ok, ListeningSocket} = gen_tcp:listen(2525, [{active, true}])
```

And for each worker, there is part in the code of the supervisor.

```
{ok, _Socket} = gen_tcp:accept(ListeningSocket)

supervisor.start_child()
```

the code executes a new worker for this client, but I don't understand 
how the child process can handle the new client connection,
because he does not pass the _Socket variable to supervisor.start_child.

Do you have a good explanation of this magic thing ?

Thank you,

Stephane
--
Stéphane Wirtel - http://wirtel.be - @matrixise


More information about the erlang-questions mailing list