java.lang.Object
java.net.SocketAddress
java.net.InetSocketAddress
org.newsclub.net.unix.AFSocketAddress
org.newsclub.net.unix.AFGenericSocketAddress
- All Implemented Interfaces:
Serializable
An
AFSocketAddress
for unknown socket types.- Author:
- Christian Kohlschütter
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.newsclub.net.unix.AFSocketAddress
AFSocketAddress.AFSocketAddressConstructor<T extends AFSocketAddress>
-
Method Summary
Modifier and TypeMethodDescriptionReturns the correspondingAFAddressFamily
.getFile()
Returns theFile
corresponding with this address, if possible.boolean
Checks if the address can be resolved to aFile
.static boolean
Checks if anInetAddress
can be unwrapped to anAFGenericSocketAddress
.static boolean
Checks if aSocketAddress
can be unwrapped to anAFGenericSocketAddress
.static AFGenericSocketAddress
Returns anAFGenericSocketAddress
for the given URI, if possible.static AFGenericSocketAddress
Returns anAFGenericSocketAddress
for the given URI, if possible.byte[]
toBytes()
Returns the native representation of this generic address, which is most likely not portable.toString()
Tries to create a URI based on thisAFSocketAddress
.static AFGenericSocketAddress
Returns anAFGenericSocketAddress
given a specialInetAddress
hostname that encodes the byte sequence of an unknown-type socket address, like those returned byAFSocketAddress.wrapAddress()
.static AFGenericSocketAddress
unwrap
(InetAddress address, int port) Returns anAFGenericSocketAddress
given a specialInetAddress
that encodes the byte sequence of an unknown-type socket address, like those returned byAFSocketAddress.wrapAddress()
.static AFGenericSocketAddress
unwrap
(SocketAddress address) Returns anAFGenericSocketAddress
given a genericSocketAddress
.Methods inherited from class org.newsclub.net.unix.AFSocketAddress
canMap, canMap, covers, getAddressFamily, getBytes, getInetAddress, getInetAddress, getInetAddress, getSocketAddress, isSupportedAddress, isUseDeserializationForInit, mapOrFail, mapOrFail, newBoundServerSocket, newConnectedSocket, newDeserializedAFSocketAddress, newForceBoundServerSocket, parseUnsignedInt, resolveAddress, toSocatAddressString, unwrap, unwrap, wrapAddress, writeNativeAddressTo
Methods inherited from class java.net.InetSocketAddress
createUnresolved, equals, getAddress, getHostName, getHostString, getPort, hashCode, isUnresolved
-
Method Details
-
unwrap
Returns anAFGenericSocketAddress
given a specialInetAddress
that encodes the byte sequence of an unknown-type socket address, like those returned byAFSocketAddress.wrapAddress()
.- Parameters:
address
- The "special"InetAddress
.port
- The port (use 0 for "none").- Returns:
- The
AFGenericSocketAddress
instance. - Throws:
SocketException
- if the operation fails, for example when an unsupported address is specified.
-
unwrap
Returns anAFGenericSocketAddress
given a specialInetAddress
hostname that encodes the byte sequence of an unknown-type socket address, like those returned byAFSocketAddress.wrapAddress()
.- Parameters:
hostname
- The "special" hostname, as provided byInetAddress.getHostName()
.port
- The port (use 0 for "none").- Returns:
- The
AFGenericSocketAddress
instance. - Throws:
SocketException
- if the operation fails, for example when an unsupported address is specified.
-
unwrap
Returns anAFGenericSocketAddress
given a genericSocketAddress
.- Parameters:
address
- The address to unwrap.- Returns:
- The
AFGenericSocketAddress
instance. - Throws:
SocketException
- if the operation fails, for example when an unsupported address is specified.
-
toString
- Overrides:
toString
in classInetSocketAddress
-
toBytes
public byte[] toBytes()Returns the native representation of this generic address, which is most likely not portable.The address contains the sa_family identifier as the first byte, and, on some platforms only, the address length, as the second byte.
- Returns:
- A new byte array containing the system-specific representation of that address.
-
hasFilename
public boolean hasFilename()Description copied from class:AFSocketAddress
Checks if the address can be resolved to aFile
.- Specified by:
hasFilename
in classAFSocketAddress
- Returns:
true
if the address has a filename.
-
getFile
Description copied from class:AFSocketAddress
Returns theFile
corresponding with this address, if possible. AFileNotFoundException
is thrown if there is no filename associated with the address, which applies to addresses in the abstract namespace, for example.- Specified by:
getFile
in classAFSocketAddress
- Returns:
- The filename.
- Throws:
FileNotFoundException
- if the address is not associated with a filename.
-
isSupportedAddress
Checks if anInetAddress
can be unwrapped to anAFGenericSocketAddress
.- Parameters:
addr
- The instance to check.- Returns:
true
if so.- See Also:
-
isSupportedAddress
Checks if aSocketAddress
can be unwrapped to anAFGenericSocketAddress
.- Parameters:
addr
- The instance to check.- Returns:
true
if so.- See Also:
-
addressFamily
Returns the correspondingAFAddressFamily
.- Returns:
- The address family instance.
-
of
Returns anAFGenericSocketAddress
for the given URI, if possible.- Parameters:
uri
- The URI.- Returns:
- The address.
- Throws:
SocketException
- if the operation fails.
-
of
Returns anAFGenericSocketAddress
for the given URI, if possible.- Parameters:
uri
- The URI.overridePort
- The port to forcibly use, or-1
for "don't override".- Returns:
- The address.
- Throws:
SocketException
- if the operation fails.
-
toURI
Description copied from class:AFSocketAddress
Tries to create a URI based on thisAFSocketAddress
.- Overrides:
toURI
in classAFSocketAddress
- Parameters:
scheme
- The target scheme.template
- An optional template to reuse certain parameters (e.g., the "path" component for anhttp
request), ornull
.- Returns:
- The URI.
- Throws:
IOException
- on error.
-