APIdia Launch Partner
Top Description Methods
jdk.internal.net.http.quic

public Interface QuicPacketReceiver

Known Direct Implementers
jdk.internal.net.http.quic.QuicConnectionImpl, jdk.internal.net.http.quic.QuicEndpoint.ClosedConnection
Imports
jdk.internal.net.http.quic.QuicEndpoint.QuicDatagram, jdk.internal.net.http.quic.packets.QuicPacket, java.net.SocketAddress, java.nio.ByteBuffer, java.util.List, .Optional

The QuicPacketReceiver is an abstraction that defines the interface between a QuicEndpoint and a QuicConnection. This defines the minimum set of methods that the endpoint will need in order to be able to dispatch a received jdk.internal.net.http.quic.packets.QuicPacket to its destination. This abstraction is typically useful when dealing with {@linkplain QuicEndpoint.ClosedConnection closed connections, which need to remain alive for a certain time after being closed in order to satisfy the requirement of the quic protocol (typically for retransmitting the CLOSE_CONNECTION frame if needed).

Method Summary

Modifier and TypeMethod and Description
public default boolean

Returns:

whether this receiver accepts packets from the given source
accepts
(SocketAddress
the sender address
source
)

Returns whether this receiver accepts packets from the given source.

public List<byte[]>
activeResetTokens()

{@return a list of active peer stateless reset tokens for this connection)

public List<QuicConnectionId>
connectionIds()

{@return a list of local connectionIds for this connection)

public default void
datagramDiscarded(QuicEndpoint.QuicDatagram
the datagram that was discarded
datagram
)

Called after a datagram has been discarded as a result of some error being raised, for instance, when an attempt to write it to the socket has failed, or if the encryption of a packet in the datagram has failed.

public default void
datagramDropped(QuicEndpoint.QuicDatagram
the datagram that was dropped
datagram
)

Called after a datagram has been dropped.

public default void
datagramSent(QuicEndpoint.QuicDatagram
the datagram that was sent
datagram
)

Called after a datagram has been written to the socket.

public default Optional<QuicConnectionId>

Returns:

the initial connection id assigned by the peer
initialConnectionId
()

Returns the initial connection id assigned by the peer.

public void
onWriteError(Throwable
the error that occurred
t
)

Called when a datagram scheduled for writing by this connection could not be written to the network.

public void
processIncoming(SocketAddress
The peer address, as received from the UDP stack
source
,
ByteBuffer
Destination connection id bytes included in the packet
destConnId
,
QuicPacket.HeadersType
The quic packet type
headersType
,
ByteBuffer
A buffer positioned at the start of the quic packet, not yet decrypted, and possibly containing coalesced packets.
buffer
)

Called when an incoming datagram is received.

public void
processStatelessReset()

Called when a stateless reset token is received.

public void
shutdown()

Called to shut a closed connection down.

Method Detail

acceptsback to summary
public default boolean accepts(SocketAddress source)

Returns whether this receiver accepts packets from the given source.

Parameters
source:SocketAddress

the sender address

Returns:boolean

whether this receiver accepts packets from the given source

activeResetTokensback to summary
public List<byte[]> activeResetTokens()

{@return a list of active peer stateless reset tokens for this connection)

connectionIdsback to summary
public List<QuicConnectionId> connectionIds()

{@return a list of local connectionIds for this connection)

datagramDiscardedback to summary
public default void datagramDiscarded(QuicEndpoint.QuicDatagram datagram)

Called after a datagram has been discarded as a result of some error being raised, for instance, when an attempt to write it to the socket has failed, or if the encryption of a packet in the datagram has failed. At this point the datagram's ByteBuffer can typically be released, or returned to a buffer pool.

Implementation Specification

The default implementation of this method does nothing.

Parameters
datagram:QuicEndpoint.QuicDatagram

the datagram that was discarded

datagramDroppedback to summary
public default void datagramDropped(QuicEndpoint.QuicDatagram datagram)

Called after a datagram has been dropped. Typically, this could happen if the datagram was only partly written, or if the connection was closed before the datagram could be sent. At this point the datagram's ByteBuffer can typically be released, or returned to a buffer pool.

Implementation Specification

The default implementation of this method does nothing.

Parameters
datagram:QuicEndpoint.QuicDatagram

the datagram that was dropped

datagramSentback to summary
public default void datagramSent(QuicEndpoint.QuicDatagram datagram)

Called after a datagram has been written to the socket. At this point the datagram's ByteBuffer can typically be released, or returned to a buffer pool.

Implementation Specification

The default implementation of this method does nothing.

Parameters
datagram:QuicEndpoint.QuicDatagram

the datagram that was sent

initialConnectionIdback to summary
public default Optional<QuicConnectionId> initialConnectionId()

Returns the initial connection id assigned by the peer. On the client side, this is always Optional#empty(). On the server side, it contains the initial connection id that was assigned by the client in the first INITIAL packet.

Implementation Specification

The default implementation of this method returns Optional#empty()

Returns:Optional<QuicConnectionId>

the initial connection id assigned by the peer

onWriteErrorback to summary
public void onWriteError(Throwable t)

Called when a datagram scheduled for writing by this connection could not be written to the network.

Parameters
t:Throwable

the error that occurred

processIncomingback to summary
public void processIncoming(SocketAddress source, ByteBuffer destConnId, QuicPacket.HeadersType headersType, ByteBuffer buffer)

Called when an incoming datagram is received.

The buffer is positioned at the start of the datagram to process. The buffer may contain more than one QUIC packet.

Parameters
source:SocketAddress

The peer address, as received from the UDP stack

destConnId:ByteBuffer

Destination connection id bytes included in the packet

headersType:QuicPacket.HeadersType

The quic packet type

buffer:ByteBuffer

A buffer positioned at the start of the quic packet, not yet decrypted, and possibly containing coalesced packets.

processStatelessResetback to summary
public void processStatelessReset()

Called when a stateless reset token is received.

shutdownback to summary
public void shutdown()

Called to shut a closed connection down. This is the last step when closing a connection, and typically only release resources held by all packet spaces.