public abstract class UdpChannelTransport extends Object implements AutoCloseable
| Modifier and Type | Field and Description |
|---|---|
protected InetSocketAddress |
connectAddress
Address to connect to if appropriate for sending.
|
protected MediaDriver.Context |
context
Context for configuration.
|
protected ErrorHandler |
errorHandler
ErrorHandler for logging errors and progressing with throwing. |
protected boolean |
isClosed
Can be used to check if the transport is closed so an operation does not proceed.
|
protected DatagramChannel |
receiveDatagramChannel
Channel to be used for receiving frames from the perspective of the endpoint.
|
protected SelectionKey |
selectionKey
To be used when polling the transport.
|
protected DatagramChannel |
sendDatagramChannel
Channel to be used for sending frames from the perspective of the endpoint.
|
protected UdpChannel |
udpChannel
Media configuration for the channel.
|
| Modifier | Constructor and Description |
|---|---|
protected |
UdpChannelTransport(UdpChannel udpChannel,
InetSocketAddress endPointAddress,
InetSocketAddress bindAddress,
InetSocketAddress connectAddress,
PortManager portManager,
MediaDriver.Context context)
Construct transport for a given channel.
|
protected |
UdpChannelTransport(UdpChannel udpChannel,
InetSocketAddress endPointAddress,
InetSocketAddress bindAddress,
InetSocketAddress connectAddress,
PortManager portManager,
MediaDriver.Context context,
int socketRcvbufLength,
int socketSndbufLength)
Construct transport for a given channel.
|
| Modifier and Type | Method and Description |
|---|---|
String |
bindAddressAndPort()
Get the bind address and port in endpoint-style format (ip:port).
|
void |
close()
Close transport, canceling any pending read operations and closing channel.
|
boolean |
isClosed()
Has the channel been closed by calling
close(). |
boolean |
isMulticast()
Is transport representing a multicast media?
|
boolean |
isValidFrame(UnsafeBuffer buffer,
int length)
Is the received frame valid.
|
int |
multicastTtl()
Get the multicast TTL value for sending datagrams on the channel.
|
void |
openDatagramChannel(AtomicCounter statusIndicator)
Open the underlying channel for reading and writing.
|
InetSocketAddress |
receive(ByteBuffer buffer)
Receive a datagram from the media layer.
|
DatagramChannel |
receiveDatagramChannel()
The
DatagramChannel for this transport channel. |
void |
receiveHook(UnsafeBuffer buffer,
int length,
InetSocketAddress address)
Receive packet hook that can be useful for logging.
|
void |
registerForRead(UdpTransportPoller transportPoller)
Register this transport for reading from a
UdpTransportPoller. |
static void |
sendError(int bytesToSend,
IOException ex,
InetSocketAddress destination)
Throw a
AeronException with a message for a send error. |
void |
sendHook(ByteBuffer buffer,
InetSocketAddress address)
Send packet hook that can be used for logging.
|
int |
socketRcvbufLength()
Get the configured OS receive socket buffer length (SO_RCVBUF) for the endpoint's socket.
|
int |
socketSndbufLength()
Get the configured OS send socket buffer length (SO_SNDBUF) for the endpoint's socket.
|
UdpChannel |
udpChannel()
Return underlying
UdpChannel. |
void |
updateEndpoint(InetSocketAddress newAddress,
AtomicCounter statusIndicator)
Endpoint has moved to a new address.
|
protected final MediaDriver.Context context
protected final ErrorHandler errorHandler
ErrorHandler for logging errors and progressing with throwing.protected final UdpChannel udpChannel
protected DatagramChannel sendDatagramChannel
protected DatagramChannel receiveDatagramChannel
protected InetSocketAddress connectAddress
protected SelectionKey selectionKey
protected boolean isClosed
protected UdpChannelTransport(UdpChannel udpChannel, InetSocketAddress endPointAddress, InetSocketAddress bindAddress, InetSocketAddress connectAddress, PortManager portManager, MediaDriver.Context context, int socketRcvbufLength, int socketSndbufLength)
udpChannel - configuration for the media.endPointAddress - to which data will be sent.bindAddress - for listening on.connectAddress - for sending data to.context - for configuration.portManager - for port binding.socketRcvbufLength - set SO_RCVBUF for socket, 0 for OS default.socketSndbufLength - set SO_SNDBUF for socket, 0 for OS default.protected UdpChannelTransport(UdpChannel udpChannel, InetSocketAddress endPointAddress, InetSocketAddress bindAddress, InetSocketAddress connectAddress, PortManager portManager, MediaDriver.Context context)
udpChannel - configuration for the media.endPointAddress - to which data will be sent.bindAddress - for listening on.connectAddress - for sending data to.portManager - for port binding.context - for configuration.public static void sendError(int bytesToSend,
IOException ex,
InetSocketAddress destination)
AeronException with a message for a send error.bytesToSend - expected to be sent to the network.ex - experienced.destination - to which the send operation was addressed.public void openDatagramChannel(AtomicCounter statusIndicator)
statusIndicator - to set for ChannelEndpointStatus which could be
ChannelEndpointStatus.ERRORED.public void registerForRead(UdpTransportPoller transportPoller)
UdpTransportPoller.transportPoller - to register for read with.public UdpChannel udpChannel()
UdpChannel.public DatagramChannel receiveDatagramChannel()
DatagramChannel for this transport channel.DatagramChannel for this transport channel.public int multicastTtl()
public String bindAddressAndPort()
Must be called after the channel is opened.
public void close()
close in interface AutoCloseablepublic boolean isClosed()
close().public boolean isMulticast()
public boolean isValidFrame(UnsafeBuffer buffer, int length)
buffer - containing the frame.length - of the frame.public void sendHook(ByteBuffer buffer, InetSocketAddress address)
buffer - containing the packet.address - to which the packet will be sent.public void receiveHook(UnsafeBuffer buffer, int length, InetSocketAddress address)
buffer - containing the packet.length - length of the packet in bytes.address - from which the packet came.public InetSocketAddress receive(ByteBuffer buffer)
buffer - into which the datagram will be received.public void updateEndpoint(InetSocketAddress newAddress, AtomicCounter statusIndicator)
newAddress - to send data to.statusIndicator - for the channelpublic int socketSndbufLength()
public int socketRcvbufLength()
Copyright © 2014-2023 Real Logic Limited. All Rights Reserved.