public abstract class UdpChannelTransport extends Object implements AutoCloseable
| Modifier and Type | Field and Description |
|---|---|
protected InetSocketAddress |
bindAddress |
protected InetSocketAddress |
connectAddress |
protected MediaDriver.Context |
context |
protected InetSocketAddress |
endPointAddress |
protected ErrorHandler |
errorHandler |
protected AtomicCounter |
invalidPackets |
protected boolean |
isClosed |
protected int |
multicastTtl |
protected DatagramChannel |
receiveDatagramChannel |
protected SelectionKey |
selectionKey |
protected DatagramChannel |
sendDatagramChannel |
protected UdpTransportPoller |
transportPoller |
protected UdpChannel |
udpChannel |
| Constructor and Description |
|---|
UdpChannelTransport(UdpChannel udpChannel,
InetSocketAddress endPointAddress,
InetSocketAddress bindAddress,
InetSocketAddress connectAddress,
MediaDriver.Context context) |
| 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 |
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 usef 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.
|
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 UdpChannel udpChannel
protected final AtomicCounter invalidPackets
protected final ErrorHandler errorHandler
protected UdpTransportPoller transportPoller
protected SelectionKey selectionKey
protected final InetSocketAddress bindAddress
protected final InetSocketAddress endPointAddress
protected InetSocketAddress connectAddress
protected DatagramChannel sendDatagramChannel
protected DatagramChannel receiveDatagramChannel
protected int multicastTtl
protected boolean isClosed
public UdpChannelTransport(UdpChannel udpChannel, InetSocketAddress endPointAddress, InetSocketAddress bindAddress, InetSocketAddress connectAddress, MediaDriver.Context context)
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 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 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 channelCopyright © 2014-2020 Real Logic Limited. All Rights Reserved.