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

William Gan <>
Fri Jan 19 11:08:13 CET 2007

On Fri, 2007-01-19 at 08:41 +0100, Per Hedeland wrote:

I had read the chapter 'Interoperability Tutorial' of Erlang/OTP
document and understood the machinery of linked-in driver. Then I traced
the call of getopts, and I understood how to modify the Erlang/OTP to
fulfill my requirement. That's my work yesterday. Today I have modified
the code to fulfill my requirement, but it is untested and broke the
rule of transplant.

Thank Serge Aleynikov and Per Hedeland for your help very much.

> 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
> linux-with-iptables-specific.
> 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
> function.
> --Per Hedeland
> >Serge
> >
> >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