Java Network Programming (3rd ed) [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Java Network Programming (3rd ed) [Electronic resources] - نسخه متنی

Harold, Elliotte Rusty

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید








6.2 Inet4Address and Inet6Address


Java 1.4 introduces two new classes, Inet4Address and
Inet6Address, in order to distinguish IPv4
addresses from IPv6 addresses:

public final class Inet4Address extends InetAddress
public final class Inet6Address extends InetAddress

(In Java 1.3 and earlier, all InetAddress objects
represent IPv4 addresses.)

Most of the time, you really shouldn't be concerned
with whether an address is an IPv4 or IPv6 address. In the
application layer where Java programs reside, you simply
don't need to know this (and even if you do need to
know, it's quicker to check the size of the byte
array returned by getAddress( ) than to use
instanceof to test which subclass you have).
Mostly these two classes are just implementation details you do not
need to concern yourself with. Inet4Address
overrides several of the methods in InetAddress
but doesn't change their behavior in any public way.
Inet6Address is similar, but it does add one new
method not present in the superclass,
isIPv4CompatibleAddress( ):

public boolean isIPv4CompatibleAddress( )

This method returns true if and only if the address is essentially an
IPv4 address stuffed into an IPv6 containerwhich means only
the last four bytes are non-zero. That is, the address has the form
0:0:0:0:0:0:0:xxxx. If this is
the case, you can pull off the last four bytes from the array
returned by getBytes( ) and use this data to
create an Inet4Address instead. However, you
rarely need to do this.


/ 164