public static class TcpDatagramSocket.Impl extends DatagramSocketImpl
DatagramSocketImpl.| Modifier and Type | Field and Description |
|---|---|
static int |
HEADER_SIZE
The fixed header size for packets.
|
static int |
PROTOCOL_MAGIC
Protcol identifier used to identify that peers are also
TcpDatagramSockets.
|
fd, localPortIP_MULTICAST_IF, IP_MULTICAST_IF2, IP_MULTICAST_LOOP, IP_TOS, SO_BINDADDR, SO_BROADCAST, SO_KEEPALIVE, SO_LINGER, SO_OOBINLINE, SO_RCVBUF, SO_REUSEADDR, SO_SNDBUF, SO_TIMEOUT, TCP_NODELAY| Constructor and Description |
|---|
Impl()
Create a new new Impl.
|
Impl(com.oracle.coherence.common.net.SocketProvider provider)
Create a new Impl using a
provider. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
bind(int nPort,
InetAddress addr) |
protected void |
bind(SocketAddress addr)
Bind the socket to the specified address.
|
protected void |
close() |
protected void |
closeInbound(com.tangosol.net.TcpDatagramSocket.Impl.ConnectionStatus status,
SocketChannel chan)
Close the inbound
channel. |
protected void |
closeOutbound(SocketAddress addr)
Close the outbound socket.
|
protected void |
create() |
protected com.tangosol.net.TcpDatagramSocket.Impl.Connection |
ensureConnection(SocketAddress addr)
Obtain a Connection for the specified address.
|
protected static SocketException |
ensureSocketException(IOException e)
Convert an IOException into a SocketException.
|
protected int |
getLocalPort() |
Object |
getOption(int nId) |
protected int |
getTimeToLive() |
protected byte |
getTTL() |
protected void |
join(InetAddress inetaddr) |
protected void |
joinGroup(SocketAddress mcastaddr,
NetworkInterface netIf) |
protected void |
leave(InetAddress inetaddr) |
protected void |
leaveGroup(SocketAddress mcastaddr,
NetworkInterface netIf) |
protected void |
logException(SocketAddress addr,
IOException e)
Log an exception which is handled internally by the TcpDatagramSocket.
|
protected void |
logProtocolWarning(SocketAddress addr,
com.tangosol.net.TcpDatagramSocket.Impl.ConnectionStatus status,
int nMagic)
Periodically log a warning when connections are made using an
unrecognized protocol.
|
protected com.tangosol.net.TcpDatagramSocket.Impl.Connection |
makeConnection(SocketAddress addr)
Produce a new Connection for the specified destination address.
|
protected SelectionKey |
nextKey(ByteBuffer buffPacket)
Perform a blocking read, waiting for a complete packet.
|
protected void |
onAccept(SelectionKey key)
Called when a channel is identified as have a new connection to
accept.
|
protected boolean |
onConnectionHeader(com.tangosol.net.TcpDatagramSocket.Impl.ConnectionStatus status,
SocketChannel chan)
Process a pending connection header.
|
protected boolean |
onRead(SelectionKey key,
ByteBuffer buffPacket)
Called when a channel is detected as readable.
|
protected int |
peek(InetAddress addr) |
protected int |
peekData(DatagramPacket packet) |
protected void |
processRegistrations()
Process any scheduled selector registrations.
|
SelectorProvider |
provider()
Return the SelectorProvider associated with this socket.
|
protected void |
receive(DatagramPacket packet) |
protected void |
scheduleRegistration(SocketChannel chan,
com.tangosol.net.TcpDatagramSocket.Impl.ConnectionStatus status)
Schedule a registration with the selector, and wake it up.
|
protected void |
send(DatagramPacket packet) |
void |
setOption(int nId,
Object oValue) |
void |
setPacketMagic(int nMagic,
int nMask)
Specify the packet header which is included at the start of every
packet.
|
protected void |
setTimeToLive(int ttl) |
protected void |
setTTL(byte ttl) |
String |
toString() |
protected int |
transferBytes(ByteBuffer buffSrc,
ByteBuffer buffDst)
Transfer bytes from the source to the destination buffer based on
their limits.
|
connect, disconnect, getFileDescriptorpublic static final int HEADER_SIZE
public static final int PROTOCOL_MAGIC
public Impl()
throws SocketException
SocketException - if any error happens during the bind, or if
the port is unavailablepublic Impl(com.oracle.coherence.common.net.SocketProvider provider)
throws SocketException
provider.provider - the provider used to create
internal socketsSocketException - if any error happens during the bind, or if
the port is unavailablepublic SelectorProvider provider()
public void setPacketMagic(int nMagic,
int nMask)
nMagic - the packet headernMask - the packet header bitmask identifying the bits used
the mask must be in byte incrementsprotected void create()
throws SocketException
create in class DatagramSocketImplSocketExceptionprotected void bind(int nPort,
InetAddress addr)
throws SocketException
bind in class DatagramSocketImplSocketExceptionprotected int getLocalPort()
getLocalPort in class DatagramSocketImplprotected void send(DatagramPacket packet) throws IOException
send in class DatagramSocketImplIOExceptionprotected int peek(InetAddress addr) throws IOException
peek in class DatagramSocketImplIOExceptionprotected int peekData(DatagramPacket packet) throws IOException
peekData in class DatagramSocketImplIOExceptionprotected void receive(DatagramPacket packet) throws IOException
receive in class DatagramSocketImplIOExceptionprotected SelectionKey nextKey(ByteBuffer buffPacket) throws IOException
buffPacket - the packet bufferSocketTimeoutException - if SO_TIMEOUT is exceededIOExceptionprotected void onAccept(SelectionKey key)
key - the associated SelectionKeyprotected boolean onRead(SelectionKey key, ByteBuffer buffPacket)
key - the associated SelectionKeybuffPacket - a buffer in which to place any available full
packetprotected boolean onConnectionHeader(com.tangosol.net.TcpDatagramSocket.Impl.ConnectionStatus status,
SocketChannel chan)
throws IOException
status - the associated ConnectionStatuschan - the associated channelIOException - if an I/O error occursprotected void close()
close in class DatagramSocketImplpublic void setOption(int nId,
Object oValue)
throws SocketException
SocketExceptionpublic Object getOption(int nId) throws SocketException
SocketExceptionprotected void setTTL(byte ttl)
throws IOException
setTTL in class DatagramSocketImplIOExceptionprotected byte getTTL()
throws IOException
getTTL in class DatagramSocketImplIOExceptionprotected void setTimeToLive(int ttl)
throws IOException
setTimeToLive in class DatagramSocketImplIOExceptionprotected int getTimeToLive()
throws IOException
getTimeToLive in class DatagramSocketImplIOExceptionprotected void join(InetAddress inetaddr) throws IOException
join in class DatagramSocketImplIOExceptionprotected void leave(InetAddress inetaddr) throws IOException
leave in class DatagramSocketImplIOExceptionprotected void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf) throws IOException
joinGroup in class DatagramSocketImplIOExceptionprotected void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf) throws IOException
leaveGroup in class DatagramSocketImplIOExceptionprotected void bind(SocketAddress addr) throws SocketException
addr - the address to bind toSocketException - if an I/O error occursprotected static SocketException ensureSocketException(IOException e)
e - the IOExcepotionprotected com.tangosol.net.TcpDatagramSocket.Impl.Connection makeConnection(SocketAddress addr) throws IOException
addr - the destination addressIOException - if an I/O error occursprotected com.tangosol.net.TcpDatagramSocket.Impl.Connection ensureConnection(SocketAddress addr) throws IOException
addr - the destination addressIOException - if an I/O error occursprotected void closeInbound(com.tangosol.net.TcpDatagramSocket.Impl.ConnectionStatus status,
SocketChannel chan)
channel.status - the ConnectionStatus corresponding to the channelchan - the channel to closeprotected void closeOutbound(SocketAddress addr)
addr - the address of the outbound socketprotected void scheduleRegistration(SocketChannel chan, com.tangosol.net.TcpDatagramSocket.Impl.ConnectionStatus status)
chan - the channel to scheduled registration forstatus - the associated ConnectionStatus to registerprotected void processRegistrations()
protected int transferBytes(ByteBuffer buffSrc, ByteBuffer buffDst)
buffSrc - the source bufferbuffDst - the destination bufferprotected void logException(SocketAddress addr, IOException e)
addr - the associated addresse - the exceptionprotected void logProtocolWarning(SocketAddress addr, com.tangosol.net.TcpDatagramSocket.Impl.ConnectionStatus status, int nMagic)
addr - the source address of the connectionstatus - the connection statusnMagic - the "magic" header they sent