[erlang-questions] How to add a option for inet:getopts

Per Hedeland <>
Fri Jan 19 08:41:44 CET 2007

Serge Aleynikov <> wrote:
>The only way to get this socket option accessible from Erlang is to add 
>support for it in the network driver (inet_drv.c).

That would be the "proper" way to do it (plus you need support at least
in inet.erl, plus ssl has its own machinery for sockets and their
options in the unlikely case that you'd want to use the option there),
and shouldn't be insurmountable. It's a bit boring though since you'd
probably need to support the mods yourself across Erlang/OTP upgrades
for all future - I'd guess that the OTP group would be reluctant to
incorporate support for the option as it is

However another way ("untested") occurred to me: You could write a small
linked-in driver to set the option, and pass it the socket file
descriptor, that you can get hold of via the undocumented inet:getfd/1

--Per Hedeland

>William Gan wrote:
>> Hello,
>> I am preparing to implement a transparent proxy by erlang, and I need an
>> equivalent call for
>> 'getsockopt(fd,SOL_IP,SO_ORIGINAL_DST,&server,&slen)'. 
>> Can anyone give me some advice how to add such a call in erlang?
>> William Gan

More information about the erlang-questions mailing list