Interface Transport
- All Known Implementing Classes:
MemoryTransport
,QuicTransport
,Transport.IP
,Transport.Socket
,Transport.TCPIP
,Transport.TCPUnix
,Transport.UDPIP
,Transport.UDPUnix
,Transport.Unix
,Transport.Wrapper
The low-level transport used by clients.
A high-level protocol such as HTTP/1.1 can be transported over a low-level protocol such as TCP/IP, Unix-Domain sockets, QUIC, shared memory, etc.
This class defines the programming interface to implement low-level protocols, and useful implementations for commonly used low-level protocols such as TCP/IP or Unix-Domain sockets.
Low-level transports may be layered; some of them maybe considered lower-level than others, but from the point of view of the high-level protocols they are all considered low-level.
For example, QUIC is typically layered on top of the UDP/IP low-level
Transport
, but it may be layered on top Unix-Domain sockets,
or on top of shared memory.
As QUIC provides a reliable, ordered, stream-based transport, it may
be seen as a replacement for TCP, and high-level protocols that need
a reliable, ordered, stream-based transport may use either the non-layered
TCP/IP or the layered QUIC over UDP/IP without noticing the difference.
This makes possible to transport HTTP/1.1 over QUIC over Unix-Domain
sockets, or HTTP/2 over QUIC over shared memory, etc.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
Abstract implementation ofTransport
based on IP.static class
Abstract implementation ofTransport
based on sockets.static class
The TCP/IPTransport
.static class
The stream Unix-Domain socketTransport
.static class
The UDP/IPTransport
.static class
The datagram Unix-Domain socketTransport
.static class
Abstract implementation ofTransport
based on Unix-Domain sockets.static class
A wrapper forTransport
instances to allow layering ofTransport
s. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
connect
(SocketAddress socketAddress, Map<String, Object> context) Establishes a connection to the given socket address.boolean
default SocketAddress
int
hashCode()
default boolean
default Connection
newConnection
(EndPoint endPoint, Map<String, Object> context) Creates a newConnection
to be associated with the given low-levelEndPoint
.default EndPoint
newEndPoint
(Scheduler scheduler, ManagedSelector selector, SelectableChannel selectable, SelectionKey selectionKey) ForTransport
s that are based on sockets, or forTransport
s that are layered on top of anotherTransport
that is based on sockets, this method is invoked to create a newEndPoint
that wraps theSelectableChannel
created bynewSelectableChannel()
.default SelectableChannel
ForTransport
s that are based on sockets, or forTransport
s that are layered on top of anotherTransport
that is based on sockets, this method is invoked to create a newSelectableChannel
used for the socket communication.default boolean
Returns whether thisTransport
requires resolution of domain names.
-
Field Details
-
TCP_IP
The TCP/IP
Transport
. -
UDP_IP
The UDP/IP
Transport
.
-
-
Method Details
-
isIntrinsicallySecure
default boolean isIntrinsicallySecure()- Returns:
- whether this
Transport
is intrinsically secure.
-
requiresDomainNameResolution
default boolean requiresDomainNameResolution()Returns whether this
Transport
requires resolution of domain names.When domain name resolution is required, it must be performed by an external service, and the value returned by
getSocketAddress()
is ignored, while the resolved socket address is eventually passed toconnect(SocketAddress, Map)
. Otherwise, domain name resolution is not required, and the value returned bygetSocketAddress()
is eventually passed toconnect(SocketAddress, Map)
.- Returns:
- whether this
Transport
requires domain names resolution
-
connect
Establishes a connection to the given socket address.
For
Transport
s thatrequire domain name resolution
, this is the IP address resolved from the domain name. ForTransport
s that do not require domain name resolution (for example Unix-Domain sockets, or memory) this is the socket address to connect to.- Parameters:
socketAddress
- the socket address to connect tocontext
- the context information to establish the connection
-
getSocketAddress
- Returns:
- the socket address to connect to in case domain name resolution is not required
-
newSelectableChannel
For
Transport
s that are based on sockets, or forTransport
s that are layered on top of anotherTransport
that is based on sockets, this method is invoked to create a newSelectableChannel
used for the socket communication.- Returns:
- a new
SelectableChannel
used for the socket communication, ornull
if the communication does not use sockets. - Throws:
IOException
- if theSelectableChannel
cannot be created
-
newEndPoint
default EndPoint newEndPoint(Scheduler scheduler, ManagedSelector selector, SelectableChannel selectable, SelectionKey selectionKey) For
Transport
s that are based on sockets, or forTransport
s that are layered on top of anotherTransport
that is based on sockets, this method is invoked to create a newEndPoint
that wraps theSelectableChannel
created bynewSelectableChannel()
.- Parameters:
scheduler
- theScheduler
selector
- theManagedSelector
selectable
- theSelectableChannel
selectionKey
- theSelectionKey
- Returns:
- a new
EndPoint
-
newConnection
Creates a new
Connection
to be associated with the given low-levelEndPoint
.For non-layered
Transport
s such as TCP/IP, theConnection
is typically that of the high-level protocol. For layeredTransport
s such as QUIC, theConnection
is typically that of the layeredTransport
.- Parameters:
endPoint
- theEndPoint
to associate theConnection
tocontext
- the context information to create the connection- Returns:
- a new
Connection
- Throws:
IOException
- if theConnection
cannot be created
-
hashCode
int hashCode() -
equals
-