java.lang.Object
java.net.Socket
org.newsclub.net.unix.AFSocket<org.newsclub.net.unix.AFTIPCSocketAddress>
org.newsclub.net.unix.tipc.AFTIPCSocket
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.newsclub.net.unix.AFSocketExtensions
,org.newsclub.net.unix.AFSomeSocket
,org.newsclub.net.unix.AFSomeSocketThing
,org.newsclub.net.unix.FileDescriptorAccess
,AFTIPCSocketExtensions
public final class AFTIPCSocket
extends org.newsclub.net.unix.AFSocket<org.newsclub.net.unix.AFTIPCSocketAddress>
implements AFTIPCSocketExtensions
Implementation of an
AF_TIPC
socket.- Author:
- Christian Kohlschütter
-
Nested Class Summary
Nested classes/interfaces inherited from class org.newsclub.net.unix.AFSocket
org.newsclub.net.unix.AFSocket.Constructor<A extends org.newsclub.net.unix.AFSocketAddress>
-
Method Summary
Modifier and TypeMethodDescriptionstatic AFTIPCSocket
connectTo
(org.newsclub.net.unix.AFTIPCSocketAddress addr) Creates a newAFSocket
and connects it to the givenAFTIPCSocketAddress
.Returns the TIPC "DestName" information from the ancillary receive buffer (if any was set), ornull
if no DestName was retrieved.Returns the TIPC "ErrInfo" information from the ancillary receive buffer (if any was set), ornull
if no error was retrieved.static String
getLinkName
(int peerId, int bearerId) Retrieves the link name given a node hash and a bearer ID.static byte[]
getNodeIdentity
(int peerId) Retrieves the 16-byte node ID given a node hash.byte[]
getNodeIdentity
(org.newsclub.net.unix.AFTIPCSocketAddress address) Retrieves the TIPC node identity given the node hash of the given address.static String
getNodeIdHexString
(int peerId) Retrieves the node ID given a node hash, as a hexadecimal string.static boolean
Returnstrue
iffAFTIPCSocket
s (sockets of type "AF_TIPC") are supported by the current Java VM and the kernel.static void
Very basic self-test function.protected AFTIPCSocketChannel
static AFTIPCSocket
Creates a new, unboundAFSocket
.static AFTIPCSocket
Creates a new, unbound, "strict"AFSocket
.Methods inherited from class org.newsclub.net.unix.AFSocket
addCloseable, bind, checkConnectionClosed, close, connect, connect, connectHook, connectTo, connectTo, ensureAncillaryReceiveBufferSize, ensureSupported, ensureUnsafeSupported, forceConnectAddress, getAncillaryReceiveBufferSize, getFileDescriptor, getImplExtensions, getInputStream, getLoadedLibrary, getLocalSocketAddress, getOutputStream, getRemoteSocketAddress, getVersion, isBound, isClosed, isConnected, isRunningOnAndroid, newInstance, removeCloseable, setAncillaryReceiveBufferSize, setShutdownOnClose, socketAddressClass, supports, supports, toString
Methods inherited from class java.net.Socket
getInetAddress, getKeepAlive, getLocalAddress, getLocalPort, getOOBInline, getOption, getPort, getReceiveBufferSize, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTrafficClass, isInputShutdown, isOutputShutdown, sendUrgentData, setKeepAlive, setOOBInline, setOption, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSocketImplFactory, setSoLinger, setSoTimeout, setTcpNoDelay, setTrafficClass, shutdownInput, shutdownOutput, supportedOptions
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.newsclub.net.unix.AFSocketExtensions
ensureAncillaryReceiveBufferSize, getAncillaryReceiveBufferSize, setAncillaryReceiveBufferSize
-
Method Details
-
isSupported
public static boolean isSupported()Returnstrue
iffAFTIPCSocket
s (sockets of type "AF_TIPC") are supported by the current Java VM and the kernel. To supportAFTIPCSocket
s, a custom JNI library must be loaded that is supplied with junixsocket, and the system must support AF_TIPC sockets. This call is equivalent to checkingAFSocket.isSupported()
andAFSocket.supports(AFSocketCapability)
withAFSocketCapability.CAPABILITY_TIPC
.- Returns:
true
iff supported.
-
newChannel
- Specified by:
newChannel
in classorg.newsclub.net.unix.AFSocket<org.newsclub.net.unix.AFTIPCSocketAddress>
-
newInstance
Creates a new, unboundAFSocket
. This "default" implementation is a bit "lenient" with respect to the specification. In particular, we ignore calls toSocket.getTcpNoDelay()
andSocket.setTcpNoDelay(boolean)
.- Returns:
- A new, unbound socket.
- Throws:
IOException
- if the operation fails.
-
newStrictInstance
Creates a new, unbound, "strict"AFSocket
. This call uses an implementation that tries to be closer to the specification thannewInstance()
, at least for some cases.- Returns:
- A new, unbound socket.
- Throws:
IOException
- if the operation fails.
-
connectTo
public static AFTIPCSocket connectTo(org.newsclub.net.unix.AFTIPCSocketAddress addr) throws IOException Creates a newAFSocket
and connects it to the givenAFTIPCSocketAddress
.- Parameters:
addr
- The address to connect to.- Returns:
- A new, connected socket.
- Throws:
IOException
- if the operation fails.
-
getChannel
- Overrides:
getChannel
in classorg.newsclub.net.unix.AFSocket<org.newsclub.net.unix.AFTIPCSocketAddress>
-
main
Very basic self-test function. Prints "supported" and "capabilities" status to System.out.- Parameters:
args
- ignored.
-
getErrInfo
Description copied from interface:AFTIPCSocketExtensions
Returns the TIPC "ErrInfo" information from the ancillary receive buffer (if any was set), ornull
if no error was retrieved.- Specified by:
getErrInfo
in interfaceAFTIPCSocketExtensions
- Returns:
- The ErrInfo.
-
getDestName
Description copied from interface:AFTIPCSocketExtensions
Returns the TIPC "DestName" information from the ancillary receive buffer (if any was set), ornull
if no DestName was retrieved.- Specified by:
getDestName
in interfaceAFTIPCSocketExtensions
- Returns:
- The service address or range (without scope) that was specified by the sender of the message.
-
getNodeIdentity
Retrieves the 16-byte node ID given a node hash.- Parameters:
peerId
- The node hash.- Returns:
- The node ID, or
null
if unsupported. - Throws:
IOException
- on error.
-
getNodeIdentity
Retrieves the TIPC node identity given the node hash of the given address.- Parameters:
address
- The address.- Returns:
- The node identity, or
null
if unsupported. - Throws:
IOException
- on error.
-
getNodeIdHexString
Retrieves the node ID given a node hash, as a hexadecimal string.- Parameters:
peerId
- The node hash.- Returns:
- The node ID, or
null
if unsupported. - Throws:
IOException
- on error.
-
getLinkName
Retrieves the link name given a node hash and a bearer ID.- Parameters:
peerId
- The node hash.bearerId
- The bearer Id.- Returns:
- The link name, or
null
if unsupported. - Throws:
IOException
- on error.
-