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, localPort
IP_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.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, getFileDescriptor
public 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.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 DatagramSocketImpl
SocketException
protected void bind(int nPort, InetAddress addr) throws SocketException
bind
in class DatagramSocketImpl
SocketException
protected int getLocalPort()
getLocalPort
in class DatagramSocketImpl
protected void send(DatagramPacket packet) throws IOException
send
in class DatagramSocketImpl
IOException
protected int peek(InetAddress addr) throws IOException
peek
in class DatagramSocketImpl
IOException
protected int peekData(DatagramPacket packet) throws IOException
peekData
in class DatagramSocketImpl
IOException
protected void receive(DatagramPacket packet) throws IOException
receive
in class DatagramSocketImpl
IOException
protected SelectionKey nextKey(ByteBuffer buffPacket) throws IOException
buffPacket
- the packet bufferSocketTimeoutException
- if SO_TIMEOUT is exceededIOException
protected 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 DatagramSocketImpl
public void setOption(int nId, Object oValue) throws SocketException
SocketException
public Object getOption(int nId) throws SocketException
SocketException
protected void setTTL(byte ttl) throws IOException
setTTL
in class DatagramSocketImpl
IOException
protected byte getTTL() throws IOException
getTTL
in class DatagramSocketImpl
IOException
protected void setTimeToLive(int ttl) throws IOException
setTimeToLive
in class DatagramSocketImpl
IOException
protected int getTimeToLive() throws IOException
getTimeToLive
in class DatagramSocketImpl
IOException
protected void join(InetAddress inetaddr) throws IOException
join
in class DatagramSocketImpl
IOException
protected void leave(InetAddress inetaddr) throws IOException
leave
in class DatagramSocketImpl
IOException
protected void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf) throws IOException
joinGroup
in class DatagramSocketImpl
IOException
protected void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf) throws IOException
leaveGroup
in class DatagramSocketImpl
IOException
protected 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