Does java.net.Inet6Address.getByName Literally Go Out and See if the Address Exists

和自甴很熟 提交于 2019-12-08 06:32:30

问题


I don't know java but as you can see from this question (Oracle Regular Expression (REGEXP_LIKE) Too Long Error - ORA-12733) java seems to be the easiest to accomplish validating if an IPv6 address is formatted correctly. I tried regular expressions, came close, but was a nightmare, and the expression is too long for PL/SQL.

I have the java in Oracle way working. I only want to validate the format, not that the address really exists. So does java.net.Inet6Address.getByName literally go out and see if the address exists?

The documentation says... (http://docs.oracle.com/javase/1.5.0/docs/api/java/net/InetAddress.html#getByName(java.lang.String))

"If a literal IP address is supplied, only the validity of the address format is checked."

I'm taking that as it does NOT ping, am I understanding that correctly?


回答1:


That is a correct understanding - it does not issue an ICMP PING.

However, it must "Go Out" to resolve the host-name (via DNS).

Of course, when an IP literal supplied, then there is no need to resolve as such .. Use this method only if attempting a name resolve is OK/desired. Be wary when using it to generally check for the validity of an IP literal.



来源:https://stackoverflow.com/questions/21922752/does-java-net-inet6address-getbyname-literally-go-out-and-see-if-the-address-exi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!