Skip to content

[eval] Set SO_REUSEADDR when binding socket to match Neko, HashLink, and hxcpp#12958

Open
joshtynjala wants to merge 1 commit into
HaxeFoundation:developmentfrom
joshtynjala:fix/so_reuseaddr
Open

[eval] Set SO_REUSEADDR when binding socket to match Neko, HashLink, and hxcpp#12958
joshtynjala wants to merge 1 commit into
HaxeFoundation:developmentfrom
joshtynjala:fix/so_reuseaddr

Conversation

@joshtynjala

Copy link
Copy Markdown

In Neko, HashLink, and hxcpp, the SO_REUSEADDR flag is set on a socket when calling the socket's bind() method on non-Windows targets.

https://github.com/HaxeFoundation/neko/blob/v2-4-1/libs/std/socket.c#L559
https://github.com/HaxeFoundation/hashlink/blob/1.15/src/std/socket.c#L284
https://github.com/HaxeFoundation/hxcpp/blob/v4.3.140/src/hx/libs/std/Socket.cpp#L810

The same is not currently true for the Haxe interpreter, which can result in the following error after exiting without closing the socket (such as when using Ctrl+C in a terminal) and then attempting to bind to the same socket again.

Unix.Unix_error(Unix.EADDRINUSE, "bind", "")

This PR brings the eval iterpreter in line with the other targets by setting the SO_REUSEADDR flag on non-Windows targets too.

See #12880 for a code sample that may be used to reproduce the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant