diff options
author | Lars Thorsen <[email protected]> | 2014-09-23 14:30:49 +0200 |
---|---|---|
committer | Lars Thorsen <[email protected]> | 2014-09-23 14:47:06 +0200 |
commit | cd14f6b5489060fb22c08e14ab0f74e7f09aa599 (patch) | |
tree | 9c91f19c6e875ae127c621a2d1a882c0e522ac9d /lib/orber/src/orber_socket.erl | |
parent | 743ed31108ee555db18d9833186865e85e34333e (diff) | |
download | otp-cd14f6b5489060fb22c08e14ab0f74e7f09aa599.tar.gz otp-cd14f6b5489060fb22c08e14ab0f74e7f09aa599.tar.bz2 otp-cd14f6b5489060fb22c08e14ab0f74e7f09aa599.zip |
[orber] Fix problem with IPv6 addresses in service context
Diffstat (limited to 'lib/orber/src/orber_socket.erl')
-rw-r--r-- | lib/orber/src/orber_socket.erl | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/lib/orber/src/orber_socket.erl b/lib/orber/src/orber_socket.erl index c8d2f0636b..4507d90cce 100644 --- a/lib/orber/src/orber_socket.erl +++ b/lib/orber/src/orber_socket.erl @@ -37,7 +37,8 @@ -export([start/0, connect/4, listen/3, listen/4, accept/2, accept/3, write/3, controlling_process/3, close/2, peername/2, sockname/2, peerdata/2, peercert/2, sockdata/2, setopts/3, - clear/2, shutdown/3, post_accept/2, post_accept/3]). + clear/2, shutdown/3, post_accept/2, post_accept/3, + get_ip_family_opts/1]). %%----------------------------------------------------------------- %% Internal exports @@ -491,4 +492,40 @@ check_options(ssl, Options, Generation) -> end. - +%%----------------------------------------------------------------- +%% Check IP Family. +get_ip_family_opts(Host) -> + case inet:parse_address(Host) of + {ok, {_,_,_,_}} -> + [inet]; + {ok, {_,_,_,_,_,_,_,_}} -> + [inet6]; + {error, einval} -> + check_family_for_name(Host, orber_env:ip_version()) + end. + +check_family_for_name(Host, inet) -> + case inet:getaddr(Host, inet) of + {ok, _Address} -> + [inet]; + {error, _} -> + case inet:getaddr(Host, inet6) of + {ok, _Address} -> + [inet6]; + {error, _} -> + [inet] + end + end; +check_family_for_name(Host, inet6) -> + case inet:getaddr(Host, inet6) of + {ok, _Address} -> + [inet6]; + {error, _} -> + case inet:getaddr(Host, inet) of + {ok, _Address} -> + [inet]; + {error, _} -> + [inet6] + end + end. + |