otp icon indicating copy to clipboard operation
otp copied to clipboard

gen_tcp:listen doesn't allow overwriting tcp_backend if `:inet` is passed

Open Munksgaard opened this issue 8 months ago • 1 comments

Describe the bug

If the inet option is passed as an option before {tcp_module, my_module}, then gen_tcp:listen does not respect the tcp_module overwrite given.

To Reproduce

gen_tcp:listen(0, [{fd, Listener}, inet, {tcp_module, my_module}])

Expected behavior

my_module is used as the backend for the listener.

Affected versions

Erlang/OTP 27

Additional context

Moving the inet option behind the tcp_module option is a workaround.

Munksgaard avatar May 10 '25 21:05 Munksgaard

If you do not specify a module, the selected module is family specific (inet_tcp for 'inet', inet6_tcp for 'inet6' and so on). I am guessing here, but its possible that the designers thought that if you specify the family before the tcp-module, family takes precedence (but then, why would you specify the tcp-module at all?). But if so, this should have been made clear in the documentation.

bmk avatar Jun 18 '25 10:06 bmk

A solution for this has been merged into master and will be released with 29.0 The reason for waiting until 29, is to avoid a potential backward compatibility issue in maintenance releases.

bmk avatar Jul 28 '25 04:07 bmk

Thank you!

Munksgaard avatar Jul 28 '25 06:07 Munksgaard