Top Description Fields Constructors Methods
org.newsclub.net.unix

public final Class AFVSOCKSocketAddress

extends AFSocketAddress
Class Inheritance
Imports
java.io.File, .FileNotFoundException, .IOException, java.net.InetAddress, .SocketAddress, .SocketException, .URI, java.nio.ByteBuffer, java.util.Arrays, .HashSet, .Locale, .Objects, .Set, java.util.regex.Matcher, .Pattern, org.newsclub.net.unix.pool.ObjectPool.Lease

An AFSocketAddress for VSOCK sockets.
Author
Christian Kohlschütter

Field Summary

Modifier and TypeField and Description
private static AFAddressFamily<AFVSOCKSocketAddress>
private static final Pattern
private static final long
public static final int
VMADDR_CID_ANY

"Any address for binding".

public static final int
VMADDR_CID_HOST

The well-known address of the host.

public static final int
VMADDR_CID_HYPERVISOR

Reserved for services built into the hypervisor.

public static final int
VMADDR_CID_LOCAL

The well-known address for local communication (loopback).

public static final int
VMADDR_PORT_ANY

Any port number for binding.

Inherited from org.newsclub.net.unix.AFSocketAddress:
INTERNAL_DUMMY_BINDINTERNAL_DUMMY_CONNECTINTERNAL_DUMMY_DONT_CONNECTSOCKETADDRESS_BUFFER_TL

Constructor Summary

AccessConstructor and Description
private
AFVSOCKSocketAddress(int port, final byte[] socketAddress, ObjectPool.Lease<ByteBuffer> nativeAddress)

Method Summary

Modifier and TypeMethod and Description
public static synchronized AFAddressFamily<AFVSOCKSocketAddress>

Returns:

The address family instance.
addressFamily
()

Returns the corresponding AFAddressFamily.

public boolean

Returns:

true if the other address could be covered.
covers
(AFSocketAddress
The other address that could be covered by this address.
covered
)

Overrides org.newsclub.net.unix.AFSocketAddress.covers.

Checks if the given address could cover another address.

public File
getFile()

Implements abstract org.newsclub.net.unix.AFSocketAddress.getFile.

Returns the File corresponding with this address, if possible.

public int

Returns:

The VSOCK CID identifier.
getVSOCKCID
()

Returns the "VSOCK CID" part of this address.

public int

Returns:

The VSOCK port identifier
getVSOCKPort
()

Returns the "VSOCK port" part of this address.

public int

Returns:

The "reserved1" identifier, which should be 0.
getVSOCKReserved1
()

Returns the "VSOCK reserved1" part of this address.

public boolean
hasFilename()

Implements abstract org.newsclub.net.unix.AFSocketAddress.hasFilename.

Checks if the address can be resolved to a File.

public static boolean

Returns:

true if so.
isSupportedAddress
(InetAddress
The instance to check.
addr
)

Checks if an InetAddress can be unwrapped to an AFVSOCKSocketAddress.

public static boolean

Returns:

true if so.
isSupportedAddress
(SocketAddress
The instance to check.
addr
)

Checks if a SocketAddress can be unwrapped to an AFVSOCKSocketAddress.

private static AFVSOCKSocketAddress
newAFSocketAddress(int port, final byte[] socketAddress, ObjectPool.Lease<ByteBuffer> nativeAddress)

public static AFVSOCKSocketAddress

Returns:

The address.
of
(URI
The URI.
uri
)

Hides org.newsclub.net.unix.AFSocketAddress.of.

Returns an AFVSOCKSocketAddress for the given URI, if possible.

public static AFVSOCKSocketAddress

Returns:

The address.
of
(URI
The URI.
uri
,
int
The port to forcibly use, or -1 for "don't override".
overridePort
)

Hides org.newsclub.net.unix.AFSocketAddress.of.

Returns an AFVSOCKSocketAddress for the given URI, if possible.

public static AFVSOCKSocketAddress

Returns:

A corresponding AFVSOCKSocketAddress instance.
ofAnyHostPort
()

Returns an AFVSOCKSocketAddress, especially useful for binding, that refers to "any" port on the host; the "java port" is set to -1.

public static AFVSOCKSocketAddress

Returns:

A corresponding AFVSOCKSocketAddress instance.
ofAnyHypervisorPort
()

Returns an AFVSOCKSocketAddress, especially useful for binding, that refers to "any" port on the hypervisor; the "java port" is set to -1.

public static AFVSOCKSocketAddress

Returns:

A corresponding AFVSOCKSocketAddress instance.
ofAnyLocalPort
()

Returns an AFVSOCKSocketAddress, especially useful for binding, that refers to "any" port with the local/loopback CID; the "java port" is set to -1.

public static AFVSOCKSocketAddress

Returns:

A corresponding AFVSOCKSocketAddress instance.
ofAnyPort
()

Returns an AFVSOCKSocketAddress, especially useful for binding, that refers to "any" port and CID; the "java port" is set to -1.

public static AFVSOCKSocketAddress

Returns:

A corresponding AFVSOCKSocketAddress instance.
ofHostPort
(int
The VSOCK port
port
)

Returns an AFVSOCKSocketAddress that refers to a given VSOCK port on the host; the "java port" is set to -1.

public static AFVSOCKSocketAddress

Returns:

A corresponding AFVSOCKSocketAddress instance.
ofHypervisorPort
(int
The VSOCK port
port
)

Returns an AFVSOCKSocketAddress that refers to a given VSOCK port on the hypervisor; the "java port" is set to -1.

public static AFVSOCKSocketAddress

Returns:

A corresponding AFVSOCKSocketAddress instance.
ofLocalPort
(int
The VSOCK port.
port
)

Returns an AFVSOCKSocketAddress that refers to the given port with the local/loopback CID; the "java port" is set to -1.

public static AFVSOCKSocketAddress

Returns:

A corresponding AFVSOCKSocketAddress instance.
ofPortAndCID
(int
The VSOCK port
port
,
int
The CID.
cid
)

Returns an AFVSOCKSocketAddress that refers to a given VSOCK port and CID; the "java port" is set to -1.

public static AFVSOCKSocketAddress

Returns:

A corresponding AFVSOCKSocketAddress instance.
ofPortAndCID
(int
The Java port number.
javaPort
,
int
The vsock port.
vsockPort
,
int
The CID.
cid
)

Returns an AFVSOCKSocketAddress that refers to a given port and CID.

public static AFVSOCKSocketAddress

Returns:

A corresponding AFVSOCKSocketAddress instance.
ofPortWithAnyCID
(int
The VSOCK port.
port
)

Returns an AFVSOCKSocketAddress, especially useful for binding, that refers to the given port with "any CID"; the "java port" is set to -1.

private static int
private static byte[]
toBytes(int port, int cid)

public String
toString()

Overrides java.net.InetSocketAddress.toString.

Constructs a string representation of this InetSocketAddress.

public URI
toURI(String
The target scheme.
scheme
,
URI
An optional template to reuse certain parameters (e.g., the "path" component for an http request), or null.
template
)

Overrides org.newsclub.net.unix.AFSocketAddress.toURI.

Tries to create a URI based on this AFSocketAddress.

public static AFVSOCKSocketAddress

Returns:

The AFVSOCKSocketAddress instance.
unwrap
(InetAddress
The "special" InetAddress.
address
,
int
The port (use 0 for "none").
port
)

Returns an AFVSOCKSocketAddress given a special InetAddress that encodes the byte sequence of an AF_VSOCK socket address, like those returned by wrapAddress().

public static AFVSOCKSocketAddress

Returns:

The AFVSOCKSocketAddress instance.
unwrap
(String
The "special" hostname, as provided by InetAddress#getHostName().
hostname
,
int
The port (use 0 for "none").
port
)

Returns an AFVSOCKSocketAddress given a special InetAddress hostname that encodes the byte sequence of an AF_VSOCK socket address, like those returned by wrapAddress().

public static AFVSOCKSocketAddress

Returns:

The AFVSOCKSocketAddress instance.
unwrap
(SocketAddress
The address to unwrap.
address
)

Returns an AFVSOCKSocketAddress given a generic SocketAddress.

Inherited from org.newsclub.net.unix.AFSocketAddress:
canMapcanMapgetAddressFamilygetBytesgetInetAddressgetInetAddressgetInetAddressgetNativeAddressDirectBuffergetNativeAddressDirectBuffergetSocketAddressisSupportedAddressisUseDeserializationForInitmapOrFailmapOrFailnewBoundServerSocketnewConnectedSocketnewDeserializedAFSocketAddressnewForceBoundServerSocketnewSockAddrDirectBuffernewSockAddrKeyBufferofInternalparseUnsignedIntpreprocessSocketAddressresolveAddresstoSocatAddressStringtoUnsignedStringtoUnsignedStringunwrapunwrapunwrapAddressDirectBufferInternalwrapAddresswriteNativeAddressTo

Field Detail

afVsockback to summary
private static AFAddressFamily<AFVSOCKSocketAddress> afVsock
PAT_VSOCK_URI_HOST_AND_PORTback to summary
private static final Pattern PAT_VSOCK_URI_HOST_AND_PORT
serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.newsclub.net.unix.AFSocketAddress.serialVersionUID.

VMADDR_CID_ANYback to summary
public static final int VMADDR_CID_ANY

"Any address for binding".

VMADDR_CID_HOSTback to summary
public static final int VMADDR_CID_HOST

The well-known address of the host.

VMADDR_CID_HYPERVISORback to summary
public static final int VMADDR_CID_HYPERVISOR

Reserved for services built into the hypervisor.

VMADDR_CID_LOCALback to summary
public static final int VMADDR_CID_LOCAL

The well-known address for local communication (loopback).

VMADDR_PORT_ANYback to summary
public static final int VMADDR_PORT_ANY

Any port number for binding.

Constructor Detail

AFVSOCKSocketAddressback to summary
private AFVSOCKSocketAddress(int port, final byte[] socketAddress, ObjectPool.Lease<ByteBuffer> nativeAddress) throws SocketException

Method Detail

addressFamilyback to summary
public static synchronized AFAddressFamily<AFVSOCKSocketAddress> addressFamily()

Returns the corresponding AFAddressFamily.

Returns:AFAddressFamily<AFVSOCKSocketAddress>

The address family instance.

Annotations
@SuppressWarnings:null
coversback to summary
public boolean covers(AFSocketAddress covered)

Overrides org.newsclub.net.unix.AFSocketAddress.covers.

Checks if the given address could cover another address. By default, this is only true if both addresses are regarded equal using equals(Object). However, implementations may support "wildcard" addresses, and this method would compare a wildcard address against some non-wildcard address, for example.

Parameters
covered:AFSocketAddress

The other address that could be covered by this address.

Returns:boolean

true if the other address could be covered.

Annotations
@Override
getFileback to summary
public File getFile() throws FileNotFoundException

Implements abstract org.newsclub.net.unix.AFSocketAddress.getFile.

Doc from org.newsclub.net.unix.AFSocketAddress.getFile.

Returns the File corresponding with this address, if possible. A FileNotFoundException is thrown if there is no filename associated with the address, which applies to addresses in the abstract namespace, for example.

Returns:File

The filename.

Annotations
@Override
Exceptions
FileNotFoundException:
if the address is not associated with a filename.
getVSOCKCIDback to summary
public int getVSOCKCID()

Returns the "VSOCK CID" part of this address.

Returns:int

The VSOCK CID identifier.

getVSOCKPortback to summary
public int getVSOCKPort()

Returns the "VSOCK port" part of this address.

Returns:int

The VSOCK port identifier

See Also
getPort()
getVSOCKReserved1back to summary
public int getVSOCKReserved1()

Returns the "VSOCK reserved1" part of this address.

Returns:int

The "reserved1" identifier, which should be 0.

hasFilenameback to summary
public boolean hasFilename()

Implements abstract org.newsclub.net.unix.AFSocketAddress.hasFilename.

Doc from org.newsclub.net.unix.AFSocketAddress.hasFilename.

Checks if the address can be resolved to a File.

Returns:boolean

true if the address has a filename.

Annotations
@Override
isSupportedAddressback to summary
public static boolean isSupportedAddress(InetAddress addr)

Checks if an InetAddress can be unwrapped to an AFVSOCKSocketAddress.

Parameters
addr:InetAddress

The instance to check.

Returns:boolean

true if so.

See Also
wrapAddress(), unwrap(InetAddress, int)
isSupportedAddressback to summary
public static boolean isSupportedAddress(SocketAddress addr)

Checks if a SocketAddress can be unwrapped to an AFVSOCKSocketAddress.

Parameters
addr:SocketAddress

The instance to check.

Returns:boolean

true if so.

See Also
unwrap(InetAddress, int)
newAFSocketAddressback to summary
private static AFVSOCKSocketAddress newAFSocketAddress(int port, final byte[] socketAddress, ObjectPool.Lease<ByteBuffer> nativeAddress) throws SocketException
ofback to summary
public static AFVSOCKSocketAddress of(URI uri) throws SocketException

Hides org.newsclub.net.unix.AFSocketAddress.of.

Returns an AFVSOCKSocketAddress for the given URI, if possible.

Parameters
uri:URI

The URI.

Returns:AFVSOCKSocketAddress

The address.

Annotations
@SuppressWarnings:PMD.ShortMethodName
Exceptions
SocketException:
if the operation fails.
ofback to summary
public static AFVSOCKSocketAddress of(URI uri, int overridePort) throws SocketException

Hides org.newsclub.net.unix.AFSocketAddress.of.

Returns an AFVSOCKSocketAddress for the given URI, if possible.

Parameters
uri:URI

The URI.

overridePort:int

The port to forcibly use, or -1 for "don't override".

Returns:AFVSOCKSocketAddress

The address.

Annotations
@SuppressWarnings:PMD.CognitiveComplexity, PMD.CyclomaticComplexity, PMD.ExcessiveMethodLength, PMD.NcssCount, PMD.NPathComplexity, PMD.ShortMethodName
Exceptions
SocketException:
if the operation fails.
ofAnyHostPortback to summary
public static AFVSOCKSocketAddress ofAnyHostPort() throws SocketException

Returns an AFVSOCKSocketAddress, especially useful for binding, that refers to "any" port on the host; the "java port" is set to -1.

Returns:AFVSOCKSocketAddress

A corresponding AFVSOCKSocketAddress instance.

Exceptions
SocketException:
if the operation fails.
ofAnyHypervisorPortback to summary
public static AFVSOCKSocketAddress ofAnyHypervisorPort() throws SocketException

Returns an AFVSOCKSocketAddress, especially useful for binding, that refers to "any" port on the hypervisor; the "java port" is set to -1.

Returns:AFVSOCKSocketAddress

A corresponding AFVSOCKSocketAddress instance.

Exceptions
SocketException:
if the operation fails.
ofAnyLocalPortback to summary
public static AFVSOCKSocketAddress ofAnyLocalPort() throws SocketException

Returns an AFVSOCKSocketAddress, especially useful for binding, that refers to "any" port with the local/loopback CID; the "java port" is set to -1.

Returns:AFVSOCKSocketAddress

A corresponding AFVSOCKSocketAddress instance.

Exceptions
SocketException:
if the operation fails.
ofAnyPortback to summary
public static AFVSOCKSocketAddress ofAnyPort() throws SocketException

Returns an AFVSOCKSocketAddress, especially useful for binding, that refers to "any" port and CID; the "java port" is set to -1.

Returns:AFVSOCKSocketAddress

A corresponding AFVSOCKSocketAddress instance.

Exceptions
SocketException:
if the operation fails.
ofHostPortback to summary
public static AFVSOCKSocketAddress ofHostPort(int port) throws SocketException

Returns an AFVSOCKSocketAddress that refers to a given VSOCK port on the host; the "java port" is set to -1.

Parameters
port:int

The VSOCK port

Returns:AFVSOCKSocketAddress

A corresponding AFVSOCKSocketAddress instance.

Exceptions
SocketException:
if the operation fails.
ofHypervisorPortback to summary
public static AFVSOCKSocketAddress ofHypervisorPort(int port) throws SocketException

Returns an AFVSOCKSocketAddress that refers to a given VSOCK port on the hypervisor; the "java port" is set to -1.

Parameters
port:int

The VSOCK port

Returns:AFVSOCKSocketAddress

A corresponding AFVSOCKSocketAddress instance.

Exceptions
SocketException:
if the operation fails.
ofLocalPortback to summary
public static AFVSOCKSocketAddress ofLocalPort(int port) throws SocketException

Returns an AFVSOCKSocketAddress that refers to the given port with the local/loopback CID; the "java port" is set to -1.

Parameters
port:int

The VSOCK port.

Returns:AFVSOCKSocketAddress

A corresponding AFVSOCKSocketAddress instance.

Exceptions
SocketException:
if the operation fails.
ofPortAndCIDback to summary
public static AFVSOCKSocketAddress ofPortAndCID(int port, int cid) throws SocketException

Returns an AFVSOCKSocketAddress that refers to a given VSOCK port and CID; the "java port" is set to -1.

Parameters
port:int

The VSOCK port

cid:int

The CID.

Returns:AFVSOCKSocketAddress

A corresponding AFVSOCKSocketAddress instance.

Exceptions
SocketException:
if the operation fails.
ofPortAndCIDback to summary
public static AFVSOCKSocketAddress ofPortAndCID(int javaPort, int vsockPort, int cid) throws SocketException

Returns an AFVSOCKSocketAddress that refers to a given port and CID.

Parameters
javaPort:int

The Java port number.

vsockPort:int

The vsock port.

cid:int

The CID.

Returns:AFVSOCKSocketAddress

A corresponding AFVSOCKSocketAddress instance.

Exceptions
SocketException:
if the operation fails.
ofPortWithAnyCIDback to summary
public static AFVSOCKSocketAddress ofPortWithAnyCID(int port) throws SocketException

Returns an AFVSOCKSocketAddress, especially useful for binding, that refers to the given port with "any CID"; the "java port" is set to -1.

Parameters
port:int

The VSOCK port.

Returns:AFVSOCKSocketAddress

A corresponding AFVSOCKSocketAddress instance.

Exceptions
SocketException:
if the operation fails.
parseIntback to summary
private static int parseInt(String v)
toBytesback to summary
private static byte[] toBytes(int port, int cid)
Annotations
@SuppressWarnings:cast
toStringback to summary
public String toString()

Overrides java.net.InetSocketAddress.toString.

Doc from java.net.InetSocketAddress.toString.

Constructs a string representation of this InetSocketAddress. This string is constructed by calling InetAddress#toString() on the InetAddress and concatenating the port number (with a colon).

If the address is an IPv6 address, the IPv6 literal is enclosed in square brackets, for example: "localhost/[0:0:0:0:0:0:0:1]:80". If the address is unresolved, <unresolved> is displayed in place of the address literal, for example "foo/<unresolved>:80".

To retrieve a string representation of the hostname or the address, use getHostString(), rather than parsing the string returned by this toString() method.

Returns:String

a string representation of this object.

Annotations
@Override
toURIback to summary
public URI toURI(String scheme, URI template) throws IOException

Overrides org.newsclub.net.unix.AFSocketAddress.toURI.

Doc from org.newsclub.net.unix.AFSocketAddress.toURI.

Tries to create a URI based on this AFSocketAddress.

Parameters
scheme:String

The target scheme.

template:URI

An optional template to reuse certain parameters (e.g., the "path" component for an http request), or null.

Returns:URI

The URI.

Annotations
@Override
@SuppressWarnings:PMD.CognitiveComplexity, PMD.CompareObjectsWithEquals
Exceptions
IOException:
on error.
unwrapback to summary
public static AFVSOCKSocketAddress unwrap(InetAddress address, int port) throws SocketException

Returns an AFVSOCKSocketAddress given a special InetAddress that encodes the byte sequence of an AF_VSOCK socket address, like those returned by wrapAddress().

Parameters
address:InetAddress

The "special" InetAddress.

port:int

The port (use 0 for "none").

Returns:AFVSOCKSocketAddress

The AFVSOCKSocketAddress instance.

Exceptions
SocketException:
if the operation fails, for example when an unsupported address is specified.
unwrapback to summary
public static AFVSOCKSocketAddress unwrap(String hostname, int port) throws SocketException

Returns an AFVSOCKSocketAddress given a special InetAddress hostname that encodes the byte sequence of an AF_VSOCK socket address, like those returned by wrapAddress().

Parameters
hostname:String

The "special" hostname, as provided by InetAddress#getHostName().

port:int

The port (use 0 for "none").

Returns:AFVSOCKSocketAddress

The AFVSOCKSocketAddress instance.

Exceptions
SocketException:
if the operation fails, for example when an unsupported address is specified.
unwrapback to summary
public static AFVSOCKSocketAddress unwrap(SocketAddress address) throws SocketException

Returns an AFVSOCKSocketAddress given a generic SocketAddress.

Parameters
address:SocketAddress

The address to unwrap.

Returns:AFVSOCKSocketAddress

The AFVSOCKSocketAddress instance.

Exceptions
SocketException:
if the operation fails, for example when an unsupported address is specified.