您的位置:首页 > 编程语言 > Java开发

[JAVA 学习笔记-63]InetAddress

2016-09-28 13:12 204 查看
Class InetAddress 【代表一个IP地址】

【This class represents an Internet Protocol (IP) address.

An IP address is either a 32-bit or 128-bit unsigned number used by IP, a lower-level protocol on which protocols like UDP and TCP are built. The IP address architecture is defined by RFC 790: Assigned Numbers, RFC 1918: Address Allocation for Private Internets,
RFC 2365: Administratively Scoped IP Multicast, and RFC 2373: IP Version 6 Addressing Architecture. An instance of an InetAddress consists of an IP address and possibly its corresponding host name (depending on whether it is constructed with a host name or
whether it has already done reverse host name resolution).】
java.lang.Object
java.net.InetAddress

All Implemented Interfaces:
Serializable

Direct Known Subclasses:
Inet4Address, Inet6Address

=====================================================

Class SocketAddress
【抽象类,代表一个socket的地址,与协议无关。
It provides an immutable object used by sockets for binding, connecting, or as returned values.】

java.lang.Object
java.net.SocketAddress

All Implemented Interfaces:
Serializable

Direct Known Subclasses:
InetSocketAddress

=======================================================

Class InetSocketAddress
【This class implements an IP Socket Address (IP address + port number) It can also be a pair (hostname + port number), in which case an attempt will be made to resolve the hostname. If resolution fails then the address is
said to be unresolved but can still be used on some circumstances like connecting through a proxy.
It provides an immutable object used by sockets for binding, connecting, or as returned values.


java.lang.Object
java.net.SocketAddress
java.net.InetSocketAddress

All Implemented Interfaces:
Serializable

=======================================================

【The differences and connections between InetAddress and SocketAddress】

differences:
As the Javadoc said,InetAddress consists of an IP address(no port information) and possibly its(the IP's) 
corresponding host name.

SocketAddress implements an socket IP address(IP address + port number),it can also be a pair(hostname+portnumber).

Major difference is with or without portnumber information.

connections:
The latter(SocketAddress) includes the former.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: