[erlang-questions] monitor sockets

Steve Vinoski vinoski@REDACTED
Sun Mar 20 15:47:44 CET 2011


On Sun, Mar 20, 2011 at 8:01 AM, Roberto Ostinelli <roberto@REDACTED> wrote:
> dear list,
>
> is there a way to monitor the closing of a socket? i've been monitoring the
> closing of sockets with the typical {tcp_closed, <Sock>} message received,
> however what if you want to monitor the port from outside the process
> actually performing the reading of the socket?
>
> i've tried link/1 since the man pages state that it could be both a process
> or a port, however to no avail.
>
> any input welcome :)

I use this feature and from what I've seen it works well. Can you
supply details or code for the kinds of problems you see?

In my embedded Yaws system we use TCP offload sockets, and I have a
special linked-in driver that interacts with our hardware to open
them. When you open an Erlang socket by supplying your own file
descriptor, as I do for this TCP offload case, the VM doesn't close
the socket file descriptor when its owning process dies as it will for
regular sockets. It instead assumes that since you opened the fd
separately, you'll take care of closing it separately too. I use
socket linking to ensure our underlying offload socket fd also gets
closed.

--steve


More information about the erlang-questions mailing list