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
Nested ClassesModifier and TypeClassDescriptionstatic final classThe 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 theFilecorresponding with this address, if possible.intgetId()Returns the "id" part of the address.@NonNull AFSYSTEMSocketAddress.SysAddrReturns the "SysAddr" part of the address.intgetUnit()Returns the "unit" part of the address.booleanChecks if the address can be resolved to aFile.static booleanChecks if anInetAddresscan be unwrapped to anAFSYSTEMSocketAddress.static booleanChecks if aSocketAddresscan be unwrapped to anAFSYSTEMSocketAddress.static AFSYSTEMSocketAddressReturns anAFSYSTEMSocketAddressfor the given URI, if possible.static AFSYSTEMSocketAddressReturns anAFSYSTEMSocketAddressfor the given URI, if possible.static AFSYSTEMSocketAddressofSysAddrIdUnit(int javaPort, AFSYSTEMSocketAddress.SysAddr sysAddr, int id, int unit) Returns anAFSYSTEMSocketAddressthat refers to a given AF_SYSTEM socket address (i.e., referring to a particular socket instance instead of a service address).static AFSYSTEMSocketAddressofSysAddrIdUnit(AFSYSTEMSocketAddress.SysAddr sysAddr, int id, int unit) Returns anAFSYSTEMSocketAddressthat 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 AFSYSTEMSocketAddressReturns anAFSYSTEMSocketAddressgiven a specialInetAddresshostname that encodes the byte sequence of an AF_SYSTEM socket address, like those returned byAFSocketAddress.wrapAddress().static AFSYSTEMSocketAddressunwrap(InetAddress address, int port) Returns anAFSYSTEMSocketAddressgiven a specialInetAddressthat encodes the byte sequence of an AF_SYSTEM socket address, like those returned byAFSocketAddress.wrapAddress().static AFSYSTEMSocketAddressunwrap(SocketAddress address) Returns anAFSYSTEMSocketAddressgiven 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, writeNativeAddressToMethods 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 anAFSYSTEMSocketAddressthat 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
AFSYSTEMSocketAddressinstance. - Throws:
SocketException- if the operation fails.
-
ofSysAddrIdUnit
public static AFSYSTEMSocketAddress ofSysAddrIdUnit(AFSYSTEMSocketAddress.SysAddr sysAddr, int id, int unit) throws SocketException Returns anAFSYSTEMSocketAddressthat 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
AFSYSTEMSocketAddressinstance. - Throws:
SocketException- if the operation fails.
-
unwrap
Returns anAFSYSTEMSocketAddressgiven a specialInetAddressthat 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
AFSYSTEMSocketAddressinstance. - Throws:
SocketException- if the operation fails, for example when an unsupported address is specified.
-
unwrap
Returns anAFSYSTEMSocketAddressgiven a specialInetAddresshostname 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
AFSYSTEMSocketAddressinstance. - Throws:
SocketException- if the operation fails, for example when an unsupported address is specified.
-
unwrap
Returns anAFSYSTEMSocketAddressgiven a genericSocketAddress.- Parameters:
address- The address to unwrap.- Returns:
- The
AFSYSTEMSocketAddressinstance. - Throws:
SocketException- if the operation fails, for example when an unsupported address is specified.
-
toString
- Overrides:
toStringin 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:AFSocketAddressChecks if the address can be resolved to aFile.- Specified by:
hasFilenamein classAFSocketAddress- Returns:
trueif the address has a filename.
-
getFile
Description copied from class:AFSocketAddressReturns theFilecorresponding with this address, if possible. AFileNotFoundExceptionis thrown if there is no filename associated with the address, which applies to addresses in the abstract namespace, for example.- Specified by:
getFilein classAFSocketAddress- Returns:
- The filename.
- Throws:
FileNotFoundException- if the address is not associated with a filename.
-
isSupportedAddress
Checks if anInetAddresscan be unwrapped to anAFSYSTEMSocketAddress.- Parameters:
addr- The instance to check.- Returns:
trueif so.- See Also:
-
isSupportedAddress
Checks if aSocketAddresscan be unwrapped to anAFSYSTEMSocketAddress.- Parameters:
addr- The instance to check.- Returns:
trueif so.- See Also:
-
addressFamily
Returns the correspondingAFAddressFamily.- Returns:
- The address family instance.
-
of
Returns anAFSYSTEMSocketAddressfor the given URI, if possible.- Parameters:
uri- The URI.- Returns:
- The address.
- Throws:
SocketException- if the operation fails.
-
of
Returns anAFSYSTEMSocketAddressfor the given URI, if possible.- Parameters:
uri- The URI.overridePort- The port to forcibly use, or-1for "don't override".- Returns:
- The address.
- Throws:
SocketException- if the operation fails.
-
toURI
Description copied from class:AFSocketAddressTries to create a URI based on thisAFSocketAddress.- Overrides:
toURIin classAFSocketAddress- Parameters:
scheme- The target scheme.template- An optional template to reuse certain parameters (e.g., the "path" component for anhttprequest), ornull.- Returns:
- The URI.
- Throws:
IOException- on error.
-