Skip to content

src/thttpd.c: Fix: bind 0.0.0.0: Address already in use#18

Open
fhost wants to merge 1 commit into
blueness:masterfrom
fhost:fhost/bind-error
Open

src/thttpd.c: Fix: bind 0.0.0.0: Address already in use#18
fhost wants to merge 1 commit into
blueness:masterfrom
fhost:fhost/bind-error

Conversation

@fhost
Copy link
Copy Markdown

@fhost fhost commented Feb 28, 2025

With no hostname, getaddrinfo() will return INADDR_ANY for ipv4 and IN6ADDR_ANY_INIT for ipv6.
Do not listen on INADDR_ANY if we already listen to IN6ADDR_ANY_INIT as it handles IPv4 as well though IPv6-mapped addresses, to avoid the bind() error.

With no hostname, `getaddrinfo()` will return INADDR_ANY for ipv4 and
IN6ADDR_ANY_INIT for ipv6.
Do not listen on INADDR_ANY if we already listen to IN6ADDR_ANY_INIT as
it handles IPv4 as well though IPv6-mapped addresses, to avoid the
`bind()` error.

Signed-off-by: Alexis Cellier <alexis.cellier@smile.fr>
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