Yes, you must add these processes to the supervisory hierarchy as you want them to be correctly / gracefully terminated when your application is stopped. (Otherwise, you will end up leaking connections that fail, because the infrastructure of the applications on which they depend is disconnected).
You can create a simple_one_for_one strategy manager, say yourapp_client_sup , which has a child specification {Id, {yourapp_client_connection, start_link_with_socket, []}, Restart, Shutdown, worker, temporary} . The temporary type is important here because usually there is no reload strategy for the connection handler - you cannot connect to the client to restart the connection. temporary here will cause the supervisor to report the exit of the connection handler, but otherwise ignore it.
The process that makes gen_tcp:accept will then create a connection handler process by executing supervisor:start_child(yourapp_client_sup, [Socket,Options,...]) , not yourapp_client_sup:start_link(Socket, Options, ...) . Make sure that the function youreapp_client_connection:start_link_with_socket starts the child through the gen_server or proc_lib ( supervisor module requirement) and that the function transfers control to the socket to the child using gen_tcp:controlling_process , otherwise the child wonβt use the socket.
An alternative approach is to create a fictitious yourapp_client_sup process that yourapp_client_sup processes can refer to at startup. The yourapp_client_sup process will exist only to propagate EXIT messages from its parent to the connection handler processes. He will have to catch the existing one and ignore all EXIT messages other than his parent's messages. In general, I prefer to use the simple_one_for_one supervisor approach.
source share