[erlang-questions] how to bind to divert socket in erlang

Michael van Slingerland <>
Thu Aug 30 16:08:56 CEST 2012


Hi,

I am working on a transparent proxy on openbsd that adds headers to
http get requests.
everything passing through the machine destined for port 80 will be
redirect through a divert-socket to a userland daemon listening on
port  8080.

In python it is quite simple:

socket.IPPROTO_DIVERT = 258
self.sock = socket.socket(socket.AF_INET, socket.SOCK_RAW,
socket.IPPROTO_DIVERT)
self.sock.bind(("0.0.0.0", port))

This makes the program listen on a divert socket on port 8080.

My question is how I can set this in erlang?
I am no erlang expert, I have been browsing through the gen_tcp an
inet docs, but no success.

Any help appreciated!

thanks,
Mike



More information about the erlang-questions mailing list