public abstract class UdpChannelTransport
extends java.lang.Object
implements java.lang.AutoCloseable
Modifier and Type | Field and Description |
---|---|
protected java.net.InetSocketAddress |
bindAddress |
protected java.net.InetSocketAddress |
connectAddress |
protected java.net.InetSocketAddress |
endPointAddress |
protected org.agrona.concurrent.errors.DistinctErrorLog |
errorLog |
protected org.agrona.concurrent.status.AtomicCounter |
invalidPackets |
protected boolean |
isClosed |
protected int |
multicastTtl |
protected java.nio.channels.DatagramChannel |
receiveDatagramChannel |
protected java.nio.channels.SelectionKey |
selectionKey |
protected java.nio.channels.DatagramChannel |
sendDatagramChannel |
protected UdpTransportPoller |
transportPoller |
protected UdpChannel |
udpChannel |
Constructor and Description |
---|
UdpChannelTransport(UdpChannel udpChannel,
java.net.InetSocketAddress endPointAddress,
java.net.InetSocketAddress bindAddress,
java.net.InetSocketAddress connectAddress,
org.agrona.concurrent.errors.DistinctErrorLog errorLog,
org.agrona.concurrent.status.AtomicCounter invalidPackets) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close transport, canceling any pending read operations and closing channel
|
boolean |
isMulticast()
Is transport representing a multicast media or unicast
|
boolean |
isValidFrame(org.agrona.concurrent.UnsafeBuffer buffer,
int length)
Is the received frame valid.
|
int |
multicastTtl()
Get the multicast TTL value for sending datagrams on the channel.
|
void |
openDatagramChannel(org.agrona.concurrent.status.AtomicCounter statusIndicator)
Create the underlying channel for reading and writing.
|
java.net.InetSocketAddress |
receive(java.nio.ByteBuffer buffer)
Receive a datagram from the media layer.
|
java.nio.channels.DatagramChannel |
receiveDatagramChannel()
The
DatagramChannel for this transport channel. |
void |
receiveHook(org.agrona.concurrent.UnsafeBuffer buffer,
int length,
java.net.InetSocketAddress address) |
void |
registerForRead(UdpTransportPoller transportPoller)
Register this transport for reading from a
UdpTransportPoller . |
static void |
sendError(int bytesToSend,
java.io.IOException ex,
java.net.InetSocketAddress destination)
Throw a
AeronException with a message for a send error. |
void |
sendHook(java.nio.ByteBuffer buffer,
java.net.InetSocketAddress address) |
UdpChannel |
udpChannel()
Return underlying
UdpChannel |
protected final UdpChannel udpChannel
protected final org.agrona.concurrent.status.AtomicCounter invalidPackets
protected final org.agrona.concurrent.errors.DistinctErrorLog errorLog
protected UdpTransportPoller transportPoller
protected java.nio.channels.SelectionKey selectionKey
protected final java.net.InetSocketAddress bindAddress
protected final java.net.InetSocketAddress endPointAddress
protected final java.net.InetSocketAddress connectAddress
protected java.nio.channels.DatagramChannel sendDatagramChannel
protected java.nio.channels.DatagramChannel receiveDatagramChannel
protected int multicastTtl
protected boolean isClosed
public UdpChannelTransport(UdpChannel udpChannel, java.net.InetSocketAddress endPointAddress, java.net.InetSocketAddress bindAddress, java.net.InetSocketAddress connectAddress, org.agrona.concurrent.errors.DistinctErrorLog errorLog, org.agrona.concurrent.status.AtomicCounter invalidPackets)
public static void sendError(int bytesToSend, java.io.IOException ex, java.net.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(org.agrona.concurrent.status.AtomicCounter statusIndicator)
statusIndicator
- to set for error statuspublic void registerForRead(UdpTransportPoller transportPoller)
UdpTransportPoller
.transportPoller
- to register read withpublic UdpChannel udpChannel()
UdpChannel
public java.nio.channels.DatagramChannel receiveDatagramChannel()
DatagramChannel
for this transport channel.DatagramChannel
for this transport channel.public int multicastTtl()
public void close()
close
in interface java.lang.AutoCloseable
public boolean isMulticast()
public boolean isValidFrame(org.agrona.concurrent.UnsafeBuffer buffer, int length)
buffer
- containing the frame.length
- of the frame.public void sendHook(java.nio.ByteBuffer buffer, java.net.InetSocketAddress address)
public void receiveHook(org.agrona.concurrent.UnsafeBuffer buffer, int length, java.net.InetSocketAddress address)
public java.net.InetSocketAddress receive(java.nio.ByteBuffer buffer)
buffer
- into which the datagram will be received.Copyright © 2014-2018 Real Logic Ltd. All Rights Reserved.