It provides an immutable object used by sockets for binding, connecting, or as returned values.
The wildcard is a special local IP address. It usually means "any"
and can only be used for bind
operations.
java.net.Socket
, java.net.ServerSocket
Modifier and Type | Class and Description |
---|---|
private static class |
Modifier and Type | Field and Description |
---|---|
private static final long | |
private final transient InetSocketAddress. | |
private static final ObjectStreamField[] | |
private static final long | |
private static final Unsafe |
Access | Constructor and Description |
---|---|
public | InetSocketAddress(int
The port number port)Creates a socket address where the IP address is the wildcard address and the port number a specified value. |
public | InetSocketAddress(InetAddress
The IP address addr, int The port number port)Creates a socket address from an IP address and a port number. |
public | InetSocketAddress(String
the Host name hostname, int The port number port)Creates a socket address from a hostname and a port number. |
private |
Modifier and Type | Method and Description |
---|---|
private static String | |
private static int | |
public static InetSocketAddress | Returns: anInetSocketAddress representing the unresolved
socket addressthe Host name host, int The port number port)Creates an unresolved socket address from a hostname and a port number. |
public final boolean | Returns: true if the objects are the same;
false otherwise.the object to compare against. obj)Overrides java. Compares this object against the specified object. |
public final InetAddress | |
public final String | |
public final String | Returns: the hostname, or String representation of the address.Returns the hostname, or the String form of the address if it doesn't have a hostname (it was created using a literal). |
public final int | |
public final int | Returns: a hash code value for this socket address.Overrides java. Returns a hashcode for this socket address. |
public final boolean | Returns: true if the hostname couldn't be resolved into
an InetAddress .Checks whether the address has been resolved or not. |
private void | readObject(ObjectInputStream
the in)ObjectInputStream from which data is readRestores the state of this object from the stream. |
private void | |
public String | Returns: a string representation of this object.Overrides java. Constructs a string representation of this InetSocketAddress. |
private void | writeObject(ObjectOutputStream
the out)ObjectOutputStream to which data is writtenWrites the state of this object to the stream. |
FIELDS_OFFSET | back to summary |
---|---|
private static final long FIELDS_OFFSET |
holder | back to summary |
---|---|
private final transient InetSocketAddress. |
serialPersistentFields | back to summary |
---|---|
private static final ObjectStreamField[] serialPersistentFields
|
serialVersionUID | back to summary |
---|---|
private static final long serialVersionUID Hides java. |
UNSAFE | back to summary |
---|---|
private static final Unsafe UNSAFE |
InetSocketAddress | back to summary |
---|---|
public InetSocketAddress(int port) Creates a socket address where the IP address is the wildcard address and the port number a specified value.
A valid port value is between 0 and 65535.
A port number of
|
InetSocketAddress | back to summary |
---|---|
public InetSocketAddress(InetAddress addr, int port) Creates a socket address from an IP address and a port number.
A valid port value is between 0 and 65535.
A port number of
A
|
InetSocketAddress | back to summary |
---|---|
public InetSocketAddress(String hostname, int port) Creates a socket address from a hostname and a port number. An attempt will be made to resolve the hostname into an InetAddress. If that attempt fails, the address will be flagged as unresolved.
If there is a security manager, its
A valid port value is between 0 and 65535.
A port number of
|
InetSocketAddress | back to summary |
---|---|
private InetSocketAddress(int port, String hostname) |
checkHost | back to summary |
---|---|
private static String checkHost(String hostname) |
checkPort | back to summary |
---|---|
private static int checkPort(int port) |
createUnresolved | back to summary |
---|---|
public static InetSocketAddress createUnresolved(String host, int port) Creates an unresolved socket address from a hostname and a port number. No attempt will be made to resolve the hostname into an InetAddress. The address will be flagged as unresolved.
A valid port value is between 0 and 65535.
A port number of
|
equals | back to summary |
---|---|
public final boolean equals(Object obj) Overrides java. Compares this object against the specified object.
The result is
Two instances of Note Hostnames are case insensitive. e.g. "FooBar" and "foobar" are considered equal.
|
getAddress | back to summary |
---|---|
public final InetAddress getAddress() Gets the
|
getHostName | back to summary |
---|---|
public final String getHostName() Gets the Note This method may trigger a name service reverse lookup if the address was created with a literal IP address.
|
getHostString | back to summary |
---|---|
public final String getHostString() Returns the hostname, or the String form of the address if it doesn't have a hostname (it was created using a literal). This has the benefit of not attempting a reverse lookup.
|
getPort | back to summary |
---|---|
public final int getPort() Gets the port number.
|
hashCode | back to summary |
---|---|
public final int hashCode() Overrides java. Returns a hashcode for this socket address.
|
isUnresolved | back to summary |
---|---|
public final boolean isUnresolved() Checks whether the address has been resolved or not.
|
readObject | back to summary |
---|---|
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException Restores the state of this object from the stream.
|
readObjectNoData | back to summary |
---|---|
private void readObjectNoData() throws ObjectStreamException Throws
|
toString | back to summary |
---|---|
public String toString() Overrides java. Constructs a string representation of this InetSocketAddress.
This string is constructed by calling
If the address is an IPv6 address, the IPv6 literal is enclosed in
square brackets, for example:
To retrieve a string representation of the hostname or the address, use
|
writeObject | back to summary |
---|---|
private void writeObject(ObjectOutputStream out) throws IOException Writes the state of this object to the stream.
|
Modifier and Type | Field and Description |
---|---|
private final InetAddress | |
private final String | |
private final int |
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
public final boolean | equals(Object
the reference object with which to compare. obj)Overrides java. Indicates whether some other object is "equal to" this one. |
private InetAddress | |
private String | |
private String | |
private int | |
public final int | |
private boolean | |
public String |
addr | back to summary |
---|---|
private final InetAddress addr |
hostname | back to summary |
---|---|
private final String hostname |
port | back to summary |
---|---|
private final int port |
InetSocketAddressHolder | back to summary |
---|---|
private InetSocketAddressHolder(String hostname, InetAddress addr, int port) |
equals | back to summary |
---|---|
public final boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
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. |
getAddress | back to summary |
---|---|
private InetAddress getAddress() |
getHostName | back to summary |
---|---|
private String getHostName() |
getHostString | back to summary |
---|---|
private String getHostString() |
getPort | back to summary |
---|---|
private int getPort() |
hashCode | back to summary |
---|---|
public final int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
|
isUnresolved | back to summary |
---|---|
private boolean isUnresolved() |
toString | back to summary |
---|---|
public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- |