Folks--<div><br></div><div>I've implemented a gen_tcp server based on the example at the end of the gen_tcp man page. In other words, it spawns 5 processes for a process pool. Each process blocks on an accept call to a listen socket, reads an incoming request, responds with a response, then loops around to block on the accept again.</div>
<div><br></div><div>The thing is, each of these processes in the process pool seems to hold a link to a port, as in, <#Port 0.123> (or something like that). I know this because I can start up the appmon, click on the process in the pool, and see an ever growing list of Ports inside the { links } tuple.</div>
<div><br></div><div>When a certain limit is reached, I get an "enfile" or "emfile" error, the process dies, the ports (or whatever they are), are reclaimed. I then spawn_link a new process to add to the pool, and off I go.</div>
<div><br></div><div>Is there some reason a process which loops over an "gen_tcp:accept" would keep holding on to the connections it gets in its link table?</div><div><br></div><div>Another wrinkle: I'm running the gen_tcp server from within a gen_server instance. The gen_service:init creates the listen socket, then spawns the process pool (via spawn_link). I use handle_info to trap a call to EXIT to spawn a new process pool instance if one of the existing ones dies.</div>
<div><br></div><div>(Mac OSX 10.5.6, Erlang R12B-5 via MacPorts)</div><div><br></div><div>Keith</div>