Class TcpTransport
java.lang.Object
org.freedesktop.dbus.connections.transports.AbstractTransport
org.freedesktop.dbus.transport.tcp.TcpTransport
- All Implemented Interfaces:
Closeable,AutoCloseable
Transport type representing a transport connection to TCP.
- Since:
- v3.2.0 - 2019-02-08
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ServerSocketChannelprivate SocketChannelprivate final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected SocketChannelMethod to accept new incoming listening connections.
This is the place whereaccept()is called on the server socket created byAbstractTransport.bindImpl().
Therefore this method will block until a client is connected.protected voidbindImpl()Listen for new connections using TCP.protected voidMethod which is called to close a transport.
Should be used to close all sockets and/or serversockets.Connect to DBus using TCP.Returns theBusAddressused for this transport.protected booleanMethod to indicate if passing of file descriptors is allowed.protected booleanisBound()Status of the server socket if this transport is configured to be a server connection.
Must be false ifAbstractTransport.bindImpl()was not called.Methods inherited from class org.freedesktop.dbus.connections.transports.AbstractTransport
close, connect, getLogger, getMessageFactory, getSaslConfig, getTransportConfig, getTransportConnection, isConnected, isFileDescriptorSupported, isListening, listen, readMessage, setPreConnectCallback, toString, writeMessage
-
Field Details
-
timeout
private final int timeout -
socket
-
serverSocket
-
-
Constructor Details
-
TcpTransport
TcpTransport(BusAddress _address, int _timeout, TransportConfig _config)
-
-
Method Details
-
hasFileDescriptorSupport
protected boolean hasFileDescriptorSupport()Description copied from class:AbstractTransportMethod to indicate if passing of file descriptors is allowed.- Specified by:
hasFileDescriptorSupportin classAbstractTransport- Returns:
- true to allow FD passing, false otherwise
-
getAddress
Description copied from class:AbstractTransportReturns theBusAddressused for this transport.- Overrides:
getAddressin classAbstractTransport- Returns:
- BusAddress, never null
-
isBound
protected boolean isBound()Description copied from class:AbstractTransportStatus of the server socket if this transport is configured to be a server connection.
Must be false ifAbstractTransport.bindImpl()was not called.- Specified by:
isBoundin classAbstractTransport- Returns:
- boolean
-
bindImpl
Listen for new connections using TCP.- Specified by:
bindImplin classAbstractTransport- Throws:
IOException- on error
-
acceptImpl
Description copied from class:AbstractTransportMethod to accept new incoming listening connections.
This is the place whereaccept()is called on the server socket created byAbstractTransport.bindImpl().
Therefore this method will block until a client is connected.- Specified by:
acceptImplin classAbstractTransport- Returns:
- newly connected client socket
- Throws:
IOException- when connection fails
-
connectImpl
Connect to DBus using TCP.- Specified by:
connectImplin classAbstractTransport- Returns:
- socket channel connected to DBus server
- Throws:
IOException- on error
-
closeTransport
Description copied from class:AbstractTransportMethod which is called to close a transport.
Should be used to close all sockets and/or serversockets.- Specified by:
closeTransportin classAbstractTransport- Throws:
IOException- when something fails while closing transport
-