java.lang.Object
java.net.SocketAddress
java.net.InetSocketAddress
org.newsclub.net.unix.AFSocketAddress
org.newsclub.net.unix.AFSYSTEMSocketAddress
- All Implemented Interfaces:
Serializable
An
AFSocketAddress
for AF_SYSTEM sockets.- Author:
- Christian Kohlschütter
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
The AF_SYSTEM system address.Nested classes/interfaces inherited from class org.newsclub.net.unix.AFSocketAddress
AFSocketAddress.AFSocketAddressConstructor<T extends AFSocketAddress>
-
Method Summary
Modifier and TypeMethodDescriptionstatic AFAddressFamily
<AFSYSTEMSocketAddress> Returns the correspondingAFAddressFamily
.getFile()
Returns theFile
corresponding with this address, if possible.int
getId()
Returns the "id" part of the address.@NonNull AFSYSTEMSocketAddress.SysAddr
Returns the "SysAddr" part of the address.int
getUnit()
Returns the "unit" part of the address.boolean
Checks if the address can be resolved to aFile
.static boolean
Checks if anInetAddress
can be unwrapped to anAFSYSTEMSocketAddress
.static boolean
Checks if aSocketAddress
can be unwrapped to anAFSYSTEMSocketAddress
.static AFSYSTEMSocketAddress
Returns anAFSYSTEMSocketAddress
for the given URI, if possible.static AFSYSTEMSocketAddress
Returns anAFSYSTEMSocketAddress
for the given URI, if possible.static AFSYSTEMSocketAddress
ofSysAddrIdUnit
(int javaPort, AFSYSTEMSocketAddress.SysAddr sysAddr, int id, int unit) Returns anAFSYSTEMSocketAddress
that refers to a given AF_SYSTEM socket address (i.e., referring to a particular socket instance instead of a service address).static AFSYSTEMSocketAddress
ofSysAddrIdUnit
(AFSYSTEMSocketAddress.SysAddr sysAddr, int id, int unit) Returns anAFSYSTEMSocketAddress
that refers to a given AF_SYSTEM socket address (i.e., referring to a particular socket instance instead of a service address).toString()
Tries to create a URI based on thisAFSocketAddress
.static AFSYSTEMSocketAddress
Returns anAFSYSTEMSocketAddress
given a specialInetAddress
hostname that encodes the byte sequence of an AF_SYSTEM socket address, like those returned byAFSocketAddress.wrapAddress()
.static AFSYSTEMSocketAddress
unwrap
(InetAddress address, int port) Returns anAFSYSTEMSocketAddress
given a specialInetAddress
that encodes the byte sequence of an AF_SYSTEM socket address, like those returned byAFSocketAddress.wrapAddress()
.static AFSYSTEMSocketAddress
unwrap
(SocketAddress address) Returns anAFSYSTEMSocketAddress
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
-
ofSysAddrIdUnit
public static AFSYSTEMSocketAddress ofSysAddrIdUnit(int javaPort, AFSYSTEMSocketAddress.SysAddr sysAddr, int id, int unit) throws SocketException Returns anAFSYSTEMSocketAddress
that refers to a given AF_SYSTEM socket address (i.e., referring to a particular socket instance instead of a service address). A Java-only "IP port number" is stored along the instance for compatibility reasons.- Parameters:
javaPort
- The emulated "port" number (not part of AF_SYSTEM).sysAddr
- 16-bit system address (e.g., AF_SYS_KERNCONTROL)id
- Controller unique identifierunit
- Developer private unit number, 0 means "unspecified".- Returns:
- A corresponding
AFSYSTEMSocketAddress
instance. - Throws:
SocketException
- if the operation fails.
-
ofSysAddrIdUnit
public static AFSYSTEMSocketAddress ofSysAddrIdUnit(AFSYSTEMSocketAddress.SysAddr sysAddr, int id, int unit) throws SocketException Returns anAFSYSTEMSocketAddress
that refers to a given AF_SYSTEM socket address (i.e., referring to a particular socket instance instead of a service address).- Parameters:
sysAddr
- 16-bit system address (e.g., AF_SYS_KERNCONTROL)id
- Controller unique identifierunit
- Developer private unit number- Returns:
- A corresponding
AFSYSTEMSocketAddress
instance. - Throws:
SocketException
- if the operation fails.
-
unwrap
Returns anAFSYSTEMSocketAddress
given a specialInetAddress
that encodes the byte sequence of an AF_SYSTEM socket address, like those returned byAFSocketAddress.wrapAddress()
.- Parameters:
address
- The "special"InetAddress
.port
- The port (use 0 for "none").- Returns:
- The
AFSYSTEMSocketAddress
instance. - Throws:
SocketException
- if the operation fails, for example when an unsupported address is specified.
-
unwrap
Returns anAFSYSTEMSocketAddress
given a specialInetAddress
hostname that encodes the byte sequence of an AF_SYSTEM 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
AFSYSTEMSocketAddress
instance. - Throws:
SocketException
- if the operation fails, for example when an unsupported address is specified.
-
unwrap
Returns anAFSYSTEMSocketAddress
given a genericSocketAddress
.- Parameters:
address
- The address to unwrap.- Returns:
- The
AFSYSTEMSocketAddress
instance. - Throws:
SocketException
- if the operation fails, for example when an unsupported address is specified.
-
toString
- Overrides:
toString
in classInetSocketAddress
-
getSysAddr
Returns the "SysAddr" part of the address.- Returns:
- The SysAddr part.
-
getId
public int getId()Returns the "id" part of the address.- Returns:
- The id part.
-
getUnit
public int getUnit()Returns the "unit" part of the address.- Returns:
- The unit part.
-
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 anAFSYSTEMSocketAddress
.- Parameters:
addr
- The instance to check.- Returns:
true
if so.- See Also:
-
isSupportedAddress
Checks if aSocketAddress
can be unwrapped to anAFSYSTEMSocketAddress
.- Parameters:
addr
- The instance to check.- Returns:
true
if so.- See Also:
-
addressFamily
Returns the correspondingAFAddressFamily
.- Returns:
- The address family instance.
-
of
Returns anAFSYSTEMSocketAddress
for the given URI, if possible.- Parameters:
uri
- The URI.- Returns:
- The address.
- Throws:
SocketException
- if the operation fails.
-
of
Returns anAFSYSTEMSocketAddress
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.
-