Skip to content

Conversation

@Kaleb-Reid
Copy link
Contributor

@Kaleb-Reid Kaleb-Reid commented Nov 1, 2025

There was already a method to get the port but I could not find a way to get the address. I noticed that the wildcard addresses have weird behaviour, not sure if I need to document that or where I would.

According to ss on Linux, when using the built-in ENet using * or :: as the bind address will actually bind to * and be accessible over IPv4 and 6, but using enet_socket_get_address will return ::. When using 0.0.0.0 as the bind address, enet_socket_get_address will return 0.0.0.0 but the socket will be bound to ::ffff:0.0.0.0 and will be accessible over IPv4 normally, but can only be accessed by IPv6 using an IPv4-mapped IPv6 address (e.g. ::ffff:7f00:1 / ::ffff:127.0.0.1).

When not using the built-in ENet, * and 0.0.0.0 will bind to 0.0.0.0 and enet_socket_get_address will return 0.0.0.0.

Given that setting :: and * both result in * being bound I chose to always return *. I also chose to leave 0.0.0.0 because its functionality is actually different from * and ::.

@Kaleb-Reid Kaleb-Reid requested review from a team as code owners November 1, 2025 07:03
ERR_FAIL_NULL_V_MSG(host, IPAddress(), "The ENetConnection instance isn't currently active.");
ERR_FAIL_COND_V_MSG(!(host->socket), IPAddress(), "The ENetConnection instance isn't currently bound.");
ENetAddress address;
ERR_FAIL_COND_V_MSG(enet_socket_get_address(host->socket, &address), IPAddress(), "Unable to get socket address");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ERR_FAIL_COND_V_MSG(enet_socket_get_address(host->socket, &address), IPAddress(), "Unable to get socket address");
ERR_FAIL_COND_V_MSG(enet_socket_get_address(host->socket, &address), IPAddress(), "Unable to get socket address.");

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants