Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

please add function to distinguish IPv6 inet_addrs #4535

Closed
vicuna opened this issue Apr 16, 2008 · 2 comments · Fixed by #9575
Closed

please add function to distinguish IPv6 inet_addrs #4535

vicuna opened this issue Apr 16, 2008 · 2 comments · Fixed by #9575

Comments

@vicuna
Copy link

vicuna commented Apr 16, 2008

Original bug ID: 4535
Reporter: ecc
Status: acknowledged (set by @damiendoligez on 2008-09-23T00:51:51Z)
Resolution: open
Priority: normal
Severity: feature
Version: 3.10.1
Category: otherlibs
Monitored by: @ygrek

Bug description

Please add a function to the Unix module that allows one to distinguish between IPv4 and IPv6 inet_addrs.

For example, when printing a sockaddr, I would like to print
1.2.3.4:666 for an IPv4 host, but
[::1]:666 for an IPv6 one.
Of course, I can search for ':' in the string returned by string_of_inet_addr, but that's a hack.

@vicuna
Copy link
Author

vicuna commented Sep 22, 2009

Comment author: @dra27

This can already be done by using Unix.domain_of_sockaddr which will return Unix.PF_INET for an IPv4 address or Unix.PF_INET6 for an IPv6 address.

However, this is tedious as it requires you to create a socket just to determine the address family of an inet_addr.

Both win32unix/unix.ml and unix/unix.ml contain a function called is_inet6_addr which is used in Unix.domain_of_sockaddr - could this function be added to unix.mli in the next release of OCaml?

@github-actions
Copy link

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

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

Successfully merging a pull request may close this issue.

1 participant