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
public class TcpDatagramSocket extends DatagramSocket
TCP based datagram socket implementation.- Author:
- mf 2009.12.03
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TcpDatagramSocket.Impl
A specialized version ofDatagramSocketImpl
.
-
Field Summary
Fields Modifier and Type Field Description static int
IO_EXCEPTIONS_LOG_LEVEL
Debbuging flag for logging an IO exceptions which occur, set to a negative to disable the logging.protected TcpDatagramSocket.Impl
m_impl
-
Constructor Summary
Constructors Modifier Constructor Description TcpDatagramSocket()
Create 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
TcpDatagramSocket(TcpDatagramSocket.Impl impl)
Creates a new TcpDatagramSocket using anTcpDatagramSocket.Impl
.TcpDatagramSocket(SocketAddress addr)
Creates a new TcpDatagramSocket which will be bound to the specifiedaddress
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isBound()
void
receive(DatagramPacket p)
void
send(DatagramPacket p)
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.String
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, setBroadcast, setDatagramSocketImplFactory, setOption, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSoTimeout, setTrafficClass, supportedOptions
-
-
-
-
Field Detail
-
IO_EXCEPTIONS_LOG_LEVEL
public static final int IO_EXCEPTIONS_LOG_LEVEL
Debbuging flag for logging an IO exceptions which occur, set to a negative to disable the logging.
-
m_impl
protected TcpDatagramSocket.Impl m_impl
-
-
Constructor Detail
-
TcpDatagramSocket
public TcpDatagramSocket() throws SocketException
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
public TcpDatagramSocket(SocketAddress addr) throws SocketException
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
public TcpDatagramSocket(int nPort) throws SocketException
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
public TcpDatagramSocket(int nPort, InetAddress addr) throws SocketException
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
protected TcpDatagramSocket(TcpDatagramSocket.Impl impl)
Creates a new TcpDatagramSocket using anTcpDatagramSocket.Impl
.- Parameters:
impl
- aTcpDatagramSocket.Impl
-
-
Method Detail
-
setSocketOptions
public void setSocketOptions(SocketOptions options) throws SocketException
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
public void setListenBacklog(int n) throws IOException
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
public void setPacketMagic(int nMagic, int nMask) throws IOException
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
public void send(DatagramPacket p) throws IOException
- Overrides:
send
in classDatagramSocket
- Throws:
IOException
-
receive
public void receive(DatagramPacket p) throws IOException
- Overrides:
receive
in classDatagramSocket
- Throws:
IOException
-
-