<div dir="ltr">This is exactly the sort of thing gen_event is for. I would make each server process register a handler at startup using gen_event:add_sup_handler() and then have the handle_event callback simply relay the event to the server processes. Yes, gproc can do this, but why incur its extra features and overhead?<div class="gmail_extra">
<br><br><div class="gmail_quote">On Sat, Aug 17, 2013 at 3:10 AM, Loïc Hoguin <span dir="ltr"><<a href="mailto:essen@ninenines.eu" target="_blank">essen@ninenines.eu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 08/17/2013 10:00 AM, Bin Wang wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
I'm new to ranch. In my application, I need to send some message to<br>
all connections. So I'd like to know can I get all connections from<br>
ranch, so I could use Transport:send to send them, or I must manage<br>
all the created connections by myself? Or is there any other better<br>
way?<br>
</blockquote>
<br></div>
The best way to do that is on your end, using gproc properties. When the connection is accepted, register the process with the property and use the property to send messages to all processes. You don't need to unregister when the connection ends, gproc does that automatically.<br>

<br>
The hackish way to do that would be to call supervisor:which_children on the ranch_conns_sup supervisor of your listener, but that will slow down the accepting of new connections, so don't do this if you need high accept rates.<span class="HOEnZb"><font color="#888888"><br>

<br>
-- <br>
Loïc Hoguin<br>
Erlang Cowboy<br>
Nine Nines<br>
<a href="http://ninenines.eu" target="_blank">http://ninenines.eu</a></font></span><div class="HOEnZb"><div class="h5"><br>
______________________________<u></u>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br></div></div>