[erlang-questions] Counters for open sockets

Rudolph van Graan rvg@REDACTED
Tue Dec 21 13:56:02 CET 2010


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
>> 
>> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3822 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20101221/76536f0e/attachment.bin>


More information about the erlang-questions mailing list