org.xsocket.datagram
Class MulticastEndpoint

Package class diagram package MulticastEndpoint
java.lang.Object
  extended by org.xsocket.datagram.MulticastEndpoint
All Implemented Interfaces:
java.io.Closeable, IConnectedEndpoint, IEndpoint

public final class MulticastEndpoint
extends java.lang.Object
implements IConnectedEndpoint

non blocking Mutlicast endpoint

Caused by the missing channel support for multicast Datagram (JSE 6.0) this class is implemented by using the "classic" MulticastSocket


Field Summary
 
Fields inherited from interface org.xsocket.datagram.IEndpoint
DEFAULT_HOST_ADDRESS, IP_MULTICAST_LOOP, IP_MULTICAST_TTL, IP_TOS, SO_BROADCAST, SO_RCVBUF, SO_REUSEADDR, SO_SNDBUF
 
Constructor Summary
MulticastEndpoint(java.net.InetAddress address, int port)
          Constructs a datagram socket and connects it to the given address
MulticastEndpoint(java.net.InetAddress address, int port, DatagramSocketConfiguration socketConfiguration)
          Deprecated.  
MulticastEndpoint(java.net.InetAddress address, int port, DatagramSocketConfiguration socketConfiguration, int receiveSize, IDatagramHandler datagramHandler)
          Deprecated.  
MulticastEndpoint(java.net.InetAddress address, int port, DatagramSocketConfiguration socketConfiguration, int receiveSize, IDatagramHandler datagramHandler, java.util.concurrent.Executor workerPool)
          Deprecated.  
MulticastEndpoint(java.net.InetAddress address, int port, int receiveSize, IDatagramHandler datagramHandler)
          Constructs a datagram socket and connects it to the given address
MulticastEndpoint(java.net.InetAddress address, int port, int receiveSize, IDatagramHandler datagramHandler, java.util.concurrent.Executor workerPool)
          Constructs a datagram socket and connects it to the given address
MulticastEndpoint(java.net.InetAddress address, int port, java.util.Map<java.lang.String,java.lang.Object> options, int receiveSize, IDatagramHandler datagramHandler, java.util.concurrent.Executor workerPool)
          Constructs a datagram socket and connects it to the given address
MulticastEndpoint(java.lang.String address, int port, DatagramSocketConfiguration socketConfiguration, int receiveSize, IDatagramHandler datagramHandler)
          Deprecated.  
MulticastEndpoint(java.lang.String address, int port, int receiveSize, IDatagramHandler datagramHandler)
          Constructs a datagram socket and connects it to the given address
 
Method Summary
 void close()
          
 java.lang.String getDefaultEncoding()
          gets the default encoding used by this endpoint
 java.lang.String getId()
          return the id
 java.net.InetAddress getLocalAddress()
          returns the address of the endpoint
 int getLocalPort()
          returns the port of the endpoint
 java.net.SocketAddress getLocalSocketAddress()
          Deprecated.  
 java.lang.Object getOption(java.lang.String name)
          returns the vlaue of a option
 java.util.Map<java.lang.String,java.lang.Class> getOptions()
          Returns an unmodifiable map of the options supported by this endpont.
 int getReceiveSize()
          get the size of the datagram that will be received
 java.net.SocketAddress getRemoteSocketAddress()
          return the connected remote address or null if not connected
 java.net.SocketOptions getSocketOptions()
          Deprecated.  
 java.util.concurrent.Executor getWorkerpool()
          return the worker pool
 IWorkerPool getWorkerPool()
          Deprecated.  
 boolean isOpen()
          returns, if the endpoint is open
 UserDatagram receive()
          receive a datagram packet (receive timeout = 0)
 UserDatagram receive(long timeoutMillis)
          receive a datagram packet
 void send(UserDatagram packet)
          send a datagram to the remote endpoint
 void setDefaultEncoding(java.lang.String defaultEncoding)
          sets the default encoding used by this endpoint
 void setReceiveSize(int receivePacketSize)
          set the size of the datagram that will be received
 void setWorkerPool(IWorkerPool workerPool)
          Deprecated.  
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xsocket.datagram.IEndpoint
getDefaultEncoding, getId, getReceiveSize, receive, receive, setDefaultEncoding, setReceiveSize, setWorkerPool
 

Constructor Detail

MulticastEndpoint

public MulticastEndpoint(java.net.InetAddress address,
                         int port)
                  throws java.io.IOException
Constructs a datagram socket and connects it to the given address

Parameters:
address - the group address
port - the port
Throws:
java.io.IOException - If some I/O error occurs

MulticastEndpoint

public MulticastEndpoint(java.net.InetAddress address,
                         int port,
                         DatagramSocketConfiguration socketConfiguration)
                  throws java.io.IOException
Deprecated. 

Throws:
java.io.IOException

MulticastEndpoint

public MulticastEndpoint(java.lang.String address,
                         int port,
                         int receiveSize,
                         IDatagramHandler datagramHandler)
                  throws java.io.IOException
Constructs a datagram socket and connects it to the given address

Parameters:
address - the group address
port - the port
receiveSize - the size of the data packet to receive
datagramHandler - the datagram handler
Throws:
java.io.IOException - If some I/O error occurs

MulticastEndpoint

public MulticastEndpoint(java.lang.String address,
                         int port,
                         DatagramSocketConfiguration socketConfiguration,
                         int receiveSize,
                         IDatagramHandler datagramHandler)
                  throws java.io.IOException
Deprecated. 

Throws:
java.io.IOException

MulticastEndpoint

public MulticastEndpoint(java.net.InetAddress address,
                         int port,
                         int receiveSize,
                         IDatagramHandler datagramHandler)
                  throws java.io.IOException
Constructs a datagram socket and connects it to the given address

Parameters:
address - the group address
port - the port
receiveSize - the size of the data packet to receive
datagramHandler - the datagram handler
Throws:
java.io.IOException - If some I/O error occurs

MulticastEndpoint

public MulticastEndpoint(java.net.InetAddress address,
                         int port,
                         int receiveSize,
                         IDatagramHandler datagramHandler,
                         java.util.concurrent.Executor workerPool)
                  throws java.io.IOException
Constructs a datagram socket and connects it to the given address

Parameters:
address - the group address
port - the port
receiveSize - the size of the data packet to receive
datagramHandler - the datagram handler
workerPool - the workerPool
Throws:
java.io.IOException - If some I/O error occurs

MulticastEndpoint

public MulticastEndpoint(java.net.InetAddress address,
                         int port,
                         DatagramSocketConfiguration socketConfiguration,
                         int receiveSize,
                         IDatagramHandler datagramHandler)
                  throws java.io.IOException
Deprecated. 

Throws:
java.io.IOException

MulticastEndpoint

public MulticastEndpoint(java.net.InetAddress address,
                         int port,
                         DatagramSocketConfiguration socketConfiguration,
                         int receiveSize,
                         IDatagramHandler datagramHandler,
                         java.util.concurrent.Executor workerPool)
                  throws java.io.IOException
Deprecated. 

Throws:
java.io.IOException

MulticastEndpoint

public MulticastEndpoint(java.net.InetAddress address,
                         int port,
                         java.util.Map<java.lang.String,java.lang.Object> options,
                         int receiveSize,
                         IDatagramHandler datagramHandler,
                         java.util.concurrent.Executor workerPool)
                  throws java.io.IOException
Constructs a datagram socket and connects it to the given address

Parameters:
address - the group address
port - the port
options - the socket options
receiveSize - the size of the data packet to receive
datagramHandler - the datagram handler
workerPool - the workerPool
Throws:
java.io.IOException - If some I/O error occurs
Method Detail

getSocketOptions

public java.net.SocketOptions getSocketOptions()
Deprecated. 


toString

public java.lang.String toString()


close

public void close()

Specified by:
close in interface java.io.Closeable

getLocalSocketAddress

public java.net.SocketAddress getLocalSocketAddress()
Deprecated. 

Specified by:
getLocalSocketAddress in interface IEndpoint

getLocalAddress

public java.net.InetAddress getLocalAddress()
returns the address of the endpoint

Specified by:
getLocalAddress in interface IEndpoint
Returns:
the address

getLocalPort

public int getLocalPort()
returns the port of the endpoint

Specified by:
getLocalPort in interface IEndpoint
Returns:
the port

getRemoteSocketAddress

public java.net.SocketAddress getRemoteSocketAddress()
return the connected remote address or null if not connected

Specified by:
getRemoteSocketAddress in interface IConnectedEndpoint
Returns:
the connected address

isOpen

public boolean isOpen()
returns, if the endpoint is open

Specified by:
isOpen in interface IEndpoint
Returns:
true if the endpoint is open

send

public void send(UserDatagram packet)
          throws ClosedConnectionException,
                 java.io.IOException
send a datagram to the remote endpoint

Specified by:
send in interface IEndpoint
Parameters:
packet - the datagram to send
Throws:
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs

getOption

public java.lang.Object getOption(java.lang.String name)
                           throws java.io.IOException
returns the vlaue of a option

Specified by:
getOption in interface IEndpoint
Parameters:
name - the name of the option
Returns:
the value of the option
Throws:
java.io.IOException - In an I/O error occurs

getOptions

public java.util.Map<java.lang.String,java.lang.Class> getOptions()
Description copied from interface: IEndpoint
Returns an unmodifiable map of the options supported by this endpont. The key in the returned map is the name of a option, and its value is the type of the option value. The returned map will never contain null keys or values.

Specified by:
getOptions in interface IEndpoint
Returns:
An unmodifiable map of the options supported by this channel

setWorkerPool

public void setWorkerPool(IWorkerPool workerPool)
Deprecated. 

set the worker pool to use

Specified by:
setWorkerPool in interface IEndpoint
Parameters:
workerPool - the worker pool to use

getWorkerPool

public IWorkerPool getWorkerPool()
Deprecated. 

return the worker pool

Returns:
the worker pool

getWorkerpool

public java.util.concurrent.Executor getWorkerpool()
return the worker pool

Returns:
the worker pool

setReceiveSize

public final void setReceiveSize(int receivePacketSize)
set the size of the datagram that will be received

Specified by:
setReceiveSize in interface IEndpoint
Parameters:
receivePacketSize - the receive size

getReceiveSize

public final int getReceiveSize()
get the size of the datagram that will be received

Specified by:
getReceiveSize in interface IEndpoint
Returns:
the receive size

receive

public final UserDatagram receive(long timeoutMillis)
                           throws java.io.IOException,
                                  java.net.SocketTimeoutException
receive a datagram packet

Specified by:
receive in interface IEndpoint
Parameters:
timeoutMillis - the receive timeout in millis
Returns:
the received datagram packet
Throws:
java.net.SocketTimeoutException - If the receive timeout has been reached
java.io.IOException - If some other I/O error occurs

receive

public UserDatagram receive()
Description copied from interface: IEndpoint
receive a datagram packet (receive timeout = 0)

Specified by:
receive in interface IEndpoint
Returns:
the received datagram packet or null if no datagram is available

getDefaultEncoding

public final java.lang.String getDefaultEncoding()
gets the default encoding used by this endpoint

Specified by:
getDefaultEncoding in interface IEndpoint
Returns:
the default encoding

setDefaultEncoding

public final void setDefaultEncoding(java.lang.String defaultEncoding)
sets the default encoding used by this endpoint

Specified by:
setDefaultEncoding in interface IEndpoint
Parameters:
defaultEncoding - the default encoding

getId

public final java.lang.String getId()
return the id

Specified by:
getId in interface IEndpoint
Returns:
the id