APIdia Launch Partner
Top Description Fields Constructors Methods
sun.nio.ch

pack-priv Class NativeSocketAddress

extends Object
Class Inheritance
Imports
java.net.Inet4Address, .Inet6Address, .InetAddress, .InetSocketAddress, .ProtocolFamily, .SocketException, .StandardProtocolFamily, .UnknownHostException, java.nio.channels.UnsupportedAddressTypeException, jdk.internal.access.JavaNetInetAddressAccess, .SharedSecrets, jdk.internal.misc.Unsafe, jdk.internal.util.ArraysSupport

A native socket address that is the union of struct sockaddr, struct sockaddr_in, and struct sockaddr_in6. This class is not thread safe.

Field Summary

Modifier and TypeField and Description
private final long
private static final int
private static final int
private static final long
private static final JavaNetInetAddressAccess
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final Unsafe

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv long
private InetAddress
address(int family)

Return an InetAddress to represent the value of the address in the sin4_addr or sin6_addr fields.

private static native int
private static native int
pack-priv static NativeSocketAddress[]
allocate(int count)

Allocate an array of native socket addresses.

pack-priv InetSocketAddress
decode()

Return an InetSocketAddress to represent the socket address in this buffer.

pack-priv int

Returns:

the size of the socket address (sizeof sockaddr or sockaddr6)
encode
(ProtocolFamily
protocol family
protocolFamily
,
InetSocketAddress
the InetSocketAddress to encode
isa
)

Encodes the given InetSocketAddress into this socket address.

public boolean
equals(Object other)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

private int
family()

Return the value of the sa_family field.

pack-priv static void
freeAll(NativeSocketAddress[] array)

Free all non-null native socket addresses in the given array.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

private int

Returns:

the byte offset of the first mismatch or -1 if no mismatch
mismatch
(NativeSocketAddress other)

Find a mismatch between this and another socket address

private static native int
private static native int
private static native int
private static native int
private static native int
private static native int
private static native int
private int
port(int family)

Return the value of the sin_port or sin6_port field.

private void
putAddress(int family, InetAddress ia)

Stores the given InetAddress in the sin_addr or sin6_addr/sin6_scope_id fields.

private static void
putAddress(long address, Inet4Address ia)

private static void
putAddress(long address, Inet6Address ia)

private void
putFamily(int family)

Stores the given family in the sa_family field.

private void
putPort(int family, int port)

Stores the given port number in the sin_port or sin6_port field.

private static native int
private static native int
private static native int
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

addressback to summary
private final long address
AF_INETback to summary
private static final int AF_INET
AF_INET6back to summary
private static final int AF_INET6
ARRAY_BASE_OFFSETback to summary
private static final long ARRAY_BASE_OFFSET
JNINAback to summary
private static final JavaNetInetAddressAccess JNINA
OFFSET_FAMILYback to summary
private static final int OFFSET_FAMILY
OFFSET_SIN4_ADDRback to summary
private static final int OFFSET_SIN4_ADDR
OFFSET_SIN4_PORTback to summary
private static final int OFFSET_SIN4_PORT
OFFSET_SIN6_ADDRback to summary
private static final int OFFSET_SIN6_ADDR
OFFSET_SIN6_FLOWINFOback to summary
private static final int OFFSET_SIN6_FLOWINFO
OFFSET_SIN6_PORTback to summary
private static final int OFFSET_SIN6_PORT
OFFSET_SIN6_SCOPE_IDback to summary
private static final int OFFSET_SIN6_SCOPE_ID
SIZEOF_FAMILYback to summary
private static final int SIZEOF_FAMILY
SIZEOF_SOCKADDR4back to summary
private static final int SIZEOF_SOCKADDR4
SIZEOF_SOCKADDR6back to summary
private static final int SIZEOF_SOCKADDR6
SIZEOF_SOCKETADDRESSback to summary
private static final int SIZEOF_SOCKETADDRESS
UNSAFEback to summary
private static final Unsafe UNSAFE

Constructor Detail

NativeSocketAddressback to summary
pack-priv NativeSocketAddress()

Method Detail

addressback to summary
pack-priv long address()
addressback to summary
private InetAddress address(int family)

Return an InetAddress to represent the value of the address in the sin4_addr or sin6_addr fields. For IPv6 addresses, the Inet6Address is created with the sin6_scope_id in the sockaddr_in6 structure.

AFINETback to summary
private static native int AFINET()
AFINET6back to summary
private static native int AFINET6()
allocateback to summary
pack-priv static NativeSocketAddress[] allocate(int count)

Allocate an array of native socket addresses.

decodeback to summary
pack-priv InetSocketAddress decode() throws SocketException

Return an InetSocketAddress to represent the socket address in this buffer.

Exceptions
SocketException:
if the socket address is not AF_INET or AF_INET6
encodeback to summary
pack-priv int encode(ProtocolFamily protocolFamily, InetSocketAddress isa)

Encodes the given InetSocketAddress into this socket address.

Parameters
protocolFamily:ProtocolFamily

protocol family

isa:InetSocketAddress

the InetSocketAddress to encode

Returns:int

the size of the socket address (sizeof sockaddr or sockaddr6)

Exceptions
UnsupportedAddressTypeException:
if the address type is not supported
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
familyback to summary
private int family()

Return the value of the sa_family field.

freeAllback to summary
pack-priv static void freeAll(NativeSocketAddress[] array)

Free all non-null native socket addresses in the given array.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
mismatchback to summary
private int mismatch(NativeSocketAddress other)

Find a mismatch between this and another socket address

Returns:int

the byte offset of the first mismatch or -1 if no mismatch

offsetFamilyback to summary
private static native int offsetFamily()
offsetSin4Addrback to summary
private static native int offsetSin4Addr()
offsetSin4Portback to summary
private static native int offsetSin4Port()
offsetSin6Addrback to summary
private static native int offsetSin6Addr()
offsetSin6FlowInfoback to summary
private static native int offsetSin6FlowInfo()
offsetSin6Portback to summary
private static native int offsetSin6Port()
offsetSin6ScopeIdback to summary
private static native int offsetSin6ScopeId()
portback to summary
private int port(int family)

Return the value of the sin_port or sin6_port field. These fields are stored in network order.

putAddressback to summary
private void putAddress(int family, InetAddress ia)

Stores the given InetAddress in the sin_addr or sin6_addr/sin6_scope_id fields. For IPv6 addresses, the sin6_addr will be popluated with an IPv4-mapped IPv6 address when the given InetAddress is an IPv4 address.

putAddressback to summary
private static void putAddress(long address, Inet4Address ia)
putAddressback to summary
private static void putAddress(long address, Inet6Address ia)
putFamilyback to summary
private void putFamily(int family)

Stores the given family in the sa_family field.

putPortback to summary
private void putPort(int family, int port)

Stores the given port number in the sin_port or sin6_port field. The port is stored in network order.

sizeofFamilyback to summary
private static native int sizeofFamily()
sizeofSockAddr4back to summary
private static native int sizeofSockAddr4()
sizeofSockAddr6back to summary
private static native int sizeofSockAddr6()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override