[erlang-questions] Counters for open sockets

Rapsey rapsey@REDACTED
Tue Dec 21 15:54:43 CET 2010


How about checking prim_inet:getfd(). This will return the FD integer and
you can detect how close to the limit you are. I'm pretty sure all systems
keep the numbers localized and don't select randomly in the available FD
space.


Sergej


On Tue, Dec 21, 2010 at 1:56 PM, Rudolph van Graan
<rvg@REDACTED>wrote:

> Hi,
>
> Thanks for both answers. I was hoping to get a light-weight function that
> supports reading hundreds of times a second. I need to be able to detect a
> race condition that triggers in a few milliseconds and end when the system
> runs out of file descriptions so that we can prevent a catastrophic
> overload. But I guess I will have to make something work with either of the
> two solutions.
>
> Thanks again.
>
>
> Rudolph van Graan
>
>
> On Dec 21, 2010, at 10:51 AM, Gleb Peregud wrote:
>
> > Take a look at inet:i() function, at unexported inet:tcp_sockets() [1]
> > and at port_list/1 function few lines below for working code of
> > approach pointed out by Kenneth
> >
> > https://github.com/erlang/otp/blob/dev/lib/kernel/src/inet.erl#L1223
> >
> > On Tue, Dec 21, 2010 at 10:43, Kenneth Lundin <kenneth.lundin@REDACTED>
> wrote:
> >> Hi,
> >>
> >> You can start like this with finding information about all ports.
> >> Every socket corresponds to a port,
> >> and every open file does also correspond to a port.
> >>
> >> [erlang:port_info(P)||P <- erlang:ports()].
> >>
> >> % this will give you a list of port_info tuples per port like this
> >> (from a new started Erlang shell)
> >> [[{name,"efile"},
> >>  {links,[<0.3.0>]},
> >>  {id,1},
> >>  {connected,<0.3.0>},
> >>  {input,0},
> >>  {output,0}],
> >>  [{name,"efile"},
> >>  {links,[<0.18.0>]},
> >>  {id,89},
> >>  {connected,<0.18.0>},
> >>  {input,0},
> >>  {output,0}],
> >>  [{name,"2/2"},
> >>  {links,[<0.21.0>]},
> >>  {id,363},
> >>  {connected,<0.21.0>},
> >>  {input,0},
> >>  {output,0}],
> >>  [{name,"tty_sl -c -e"},
> >>  {links,[<0.23.0>]},
> >>  {id,372},
> >>  {connected,<0.23.0>},
> >>  {input,107},
> >>  {output,762}]]
> >>
> >>
> >> /Kenneth , Erlang/OTP Ericssson
> >>
> >>
> >> On Tue, Dec 21, 2010 at 10:30 AM, Rudolph van Graan
> >> <rvg@REDACTED> wrote:
> >>> Hi,
> >>>
> >>> Are there any built-in mechanisms in Erlang for knowing how many open
> sockets a VM has (or open files for that matter)?
> >>>
> >>> Thanks
> >>>
> >>> Rudolph
> >>
> >> ________________________________________________________________
> >> erlang-questions (at) erlang.org mailing list.
> >> See http://www.erlang.org/faq.html
> >> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
> >>
> >>
>
>


More information about the erlang-questions mailing list