Package com.tangosol.net
Class TcpDatagramSocket
java.lang.Object
java.net.DatagramSocket
com.tangosol.net.TcpDatagramSocket
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
NonBlockingTcpDatagramSocket
TCP based datagram socket implementation.
- Author:
- mf 2009.12.03
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Debbuging flag for logging an IO exceptions which occur, set to a negative to disable the logging.protected TcpDatagramSocket.Impl
-
Constructor Summary
ModifierConstructorDescriptionCreate a new TcpDatagramSocket that with a wildcard address bound to an ephemeral port.TcpDatagramSocket
(int nPort) Creates a new TcpDatagramSocket using the wildcard address and the specified port.TcpDatagramSocket
(int nPort, InetAddress addr) Creates a new TcpDatagramSocket using anaddress
and a port number.TcpDatagramSocket
(com.oracle.coherence.common.net.SocketProvider provider) Creates a new TcpDatagramSocket using theprovider
.protected
Creates a new TcpDatagramSocket using anTcpDatagramSocket.Impl
.Creates a new TcpDatagramSocket which will be bound to the specifiedaddress
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
isBound()
void
void
void
setAdvanceFrequency
(int nAdvance) Specify the frequency at which the DatagramSocket will advance over the sub-sockets during receive.void
setListenBacklog
(int n) Specify the listen backlog for the server socket.void
setPacketMagic
(int nMagic, int nMask) Specify the packet header which is included at the start of every packet.void
setSocketOptions
(SocketOptions options) Specify SocketOptions to be used to configure each of the underlying TCP sockets.toString()
Methods inherited from class java.net.DatagramSocket
bind, close, connect, connect, disconnect, getBroadcast, getChannel, getInetAddress, getLocalAddress, getLocalPort, getLocalSocketAddress, getOption, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoTimeout, getTrafficClass, isClosed, isConnected, joinGroup, leaveGroup, setBroadcast, setDatagramSocketImplFactory, setOption, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSoTimeout, setTrafficClass, supportedOptions
-
Field Details
-
IO_EXCEPTIONS_LOG_LEVEL
public static final int IO_EXCEPTIONS_LOG_LEVELDebbuging flag for logging an IO exceptions which occur, set to a negative to disable the logging. -
m_impl
-
-
Constructor Details
-
TcpDatagramSocket
Create a new TcpDatagramSocket that with a wildcard address bound to an ephemeral port.- Throws:
SocketException
- if any error happens during the bind, or if the port is unavailable
-
TcpDatagramSocket
Creates a new TcpDatagramSocket which will be bound to the specifiedaddress
.- Parameters:
addr
- theaddress
to bind- Throws:
SocketException
- if any error happens during the bind, or if the port is unavailable
-
TcpDatagramSocket
Creates a new TcpDatagramSocket using the wildcard address and the specified port.The port number should be between 0 and 65535. Zero means that the system will pick an ephemeral port during the bind operation.
- Parameters:
nPort
- the port to bind to- Throws:
SocketException
- if any error happens during the bind, or if the port is unavailable
-
TcpDatagramSocket
Creates a new TcpDatagramSocket using anaddress
and a port number.If
null
is specified as the address assigned will be the wildcard address.The port number should be between 0 and 65535. Zero means that the system will pick an ephemeral port during the bind operation.
- Parameters:
nPort
- the port numberaddr
- the IP address- Throws:
SocketException
- if any error happens during the bind, or if the port is unavailable
-
TcpDatagramSocket
public TcpDatagramSocket(com.oracle.coherence.common.net.SocketProvider provider) throws SocketException Creates a new TcpDatagramSocket using theprovider
.- Parameters:
provider
- theprovider
to be used- Throws:
SocketException
- if any error happens during the bind, or if the port is unavailable
-
TcpDatagramSocket
Creates a new TcpDatagramSocket using anTcpDatagramSocket.Impl
.- Parameters:
impl
- aTcpDatagramSocket.Impl
-
-
Method Details
-
setSocketOptions
Specify SocketOptions to be used to configure each of the underlying TCP sockets. These options will be added to any previously specified options.- Parameters:
options
- the SocketOptions- Throws:
SocketException
- if the options fail to be set
-
setListenBacklog
Specify the listen backlog for the server socket.- Parameters:
n
- the depth of the backlog, or <=0 for the OS default.- Throws:
IOException
- if the port is unavailable
-
setPacketMagic
Specify the packet header which is included at the start of every packet. Because this implementation is TCP based these headers can be stripped off, and replaced on the far side without consuming any network resources.- Parameters:
nMagic
- the packet headernMask
- the packet header bitmask identifying the bits used- Throws:
IOException
- if the port is unavailable
-
setAdvanceFrequency
public void setAdvanceFrequency(int nAdvance) Specify the frequency at which the DatagramSocket will advance over the sub-sockets during receive. A higher value will optimize for throughput as well as latency when communicating with a small number of peers. A low value will optimize for latency when communicating with a large number of peers, but is likely to hurt overall throughput.- Parameters:
nAdvance
- the packet frequency at which to advance between peers
-
isBound
public boolean isBound()- Overrides:
isBound
in classDatagramSocket
-
send
- Overrides:
send
in classDatagramSocket
- Throws:
IOException
-
receive
- Overrides:
receive
in classDatagramSocket
- Throws:
IOException
-
toString
-