Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


com.tangosol.net
Class TcpDatagramSocket

java.lang.Object
  extended by java.net.DatagramSocket
      extended by com.tangosol.net.TcpDatagramSocket

Direct Known Subclasses:
NonBlockingTcpDatagramSocket

public class TcpDatagramSocket
extends java.net.DatagramSocket

TCP based datagram socket implementation.

Author:
mf 2009.12.03

Nested Class Summary
static class TcpDatagramSocket.Impl
          A specialized version of DatagramSocketImpl.

 

Field Summary
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
  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, java.net.InetAddress addr)
          Creates a new TcpDatagramSocket using an address and a port number.
  TcpDatagramSocket(java.net.SocketAddress addr)
          Creates a new TcpDatagramSocket which will be bound to the specified address.
  TcpDatagramSocket(SocketProvider provider)
          Creates a new TcpDatagramSocket using the provider.
protected TcpDatagramSocket(TcpDatagramSocket.Impl impl)
          Creates a new TcpDatagramSocket using an TcpDatagramSocket.Impl.

 

Method Summary
 void bind(java.net.SocketAddress addr)
          
 boolean isBound()
          
 java.nio.channels.spi.SelectorProvider provider()
          Return the SelectorProvider associated with this socket.
 void receive(java.net.DatagramPacket p)
          
 void send(java.net.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(java.net.SocketOptions options)
          Specify SocketOptions to be used to configure each of the underlying TCP sockets.
 java.lang.String toString()
          

 

Methods inherited from class java.net.DatagramSocket
close, connect, connect, disconnect, getBroadcast, getChannel, getInetAddress, getLocalAddress, getLocalPort, getLocalSocketAddress, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoTimeout, getTrafficClass, isClosed, isConnected, setBroadcast, setDatagramSocketImplFactory, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSoTimeout, setTrafficClass

 

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 java.net.SocketException
Create a new TcpDatagramSocket that with a wildcard address bound to an ephemeral port.
Throws:
java.net.SocketException - if any error happens during the bind, or if the port is unavailable

TcpDatagramSocket

public TcpDatagramSocket(java.net.SocketAddress addr)
                  throws java.net.SocketException
Creates a new TcpDatagramSocket which will be bound to the specified address.
Parameters:
addr - the address to bind
Throws:
java.net.SocketException - if any error happens during the bind, or if the port is unavailable

TcpDatagramSocket

public TcpDatagramSocket(int nPort)
                  throws java.net.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:
java.net.SocketException - if any error happens during the bind, or if the port is unavailable

TcpDatagramSocket

public TcpDatagramSocket(int nPort,
                         java.net.InetAddress addr)
                  throws java.net.SocketException
Creates a new TcpDatagramSocket using an address 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 number
addr - the IP address
Throws:
java.net.SocketException - if any error happens during the bind, or if the port is unavailable

TcpDatagramSocket

public TcpDatagramSocket(SocketProvider provider)
                  throws java.net.SocketException
Creates a new TcpDatagramSocket using the provider.
Parameters:
provider - the provider to be used
Throws:
java.net.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 an TcpDatagramSocket.Impl.
Parameters:
impl - a TcpDatagramSocket.Impl

Method Detail

provider

public java.nio.channels.spi.SelectorProvider provider()
Return the SelectorProvider associated with this socket.
Returns:
the SelectorProvider

setSocketOptions

public void setSocketOptions(java.net.SocketOptions options)
                      throws java.net.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:
java.net.SocketException - if the options fail to be set

setListenBacklog

public void setListenBacklog(int n)
                      throws java.io.IOException
Specify the listen backlog for the server socket.
Parameters:
n - the depth of the backlog, or <=0 for the OS default.
Throws:
java.io.IOException - if the port is unavailable

setPacketMagic

public void setPacketMagic(int nMagic,
                           int nMask)
                    throws java.io.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 header
nMask - the packet header bitmask identifying the bits used
Throws:
java.io.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

bind

public void bind(java.net.SocketAddress addr)
          throws java.net.SocketException
Overrides:
bind in class java.net.DatagramSocket
Throws:
java.net.SocketException

isBound

public boolean isBound()
Overrides:
isBound in class java.net.DatagramSocket

send

public void send(java.net.DatagramPacket p)
          throws java.io.IOException
Overrides:
send in class java.net.DatagramSocket
Throws:
java.io.IOException

receive

public void receive(java.net.DatagramPacket p)
             throws java.io.IOException
Overrides:
receive in class java.net.DatagramSocket
Throws:
java.io.IOException

toString

public java.lang.String toString()

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.