p2ps.imp.endpoint.UDP
Class UDPMulticastEndpoint

java.lang.Object
  extended byp2ps.imp.endpoint.UDP.UDPEndpoint
      extended byp2ps.imp.endpoint.UDP.UDPMulticastEndpoint
All Implemented Interfaces:
Endpoint, UDPEndpointSchemes

public class UDPMulticastEndpoint
extends UDPEndpoint

An extension to UDPOutputEndpoint that enables sendind to a multicast address.

Version:
$Revision: 295 $
Author:
Ian Wang

Nested Class Summary
 
Nested classes inherited from class p2ps.imp.endpoint.UDP.UDPEndpoint
UDPEndpoint.DefaultInputMonitorFactory
 
Field Summary
 
Fields inherited from class p2ps.imp.endpoint.UDP.UDPEndpoint
MAX_DATAGRAM_SIZE, monfactory, RECEIVE_BUFFER_SIZE, SEND_BUFFER_SIZE, socket, SOCKET_TIMEOUT
 
Fields inherited from interface p2ps.imp.endpoint.UDP.UDPEndpointSchemes
UDP_MULTICAST, UDP_STANDARD
 
Constructor Summary
UDPMulticastEndpoint(boolean discovery)
          Creates a multicast socket attached to a new port
UDPMulticastEndpoint(java.lang.String groupaddr, int port)
          Creates a multicast socket attaches to the specified group address and port
 
Method Summary
 java.net.URI getEndpointURI()
           
 java.net.URI getSendURI()
           
protected  void initSocket(int port, boolean input)
          Initialises the socket
 boolean isOutputEndpoint()
           
 void send(byte[] message)
          Sends a message from the endpoint to the address the endpoint is bound to, with no sendid.
 void send(java.lang.String sendid, byte[] message)
          Sends a message from the endpoint to the address the endpoint is bound to, along with the send id for this message.
 
Methods inherited from class p2ps.imp.endpoint.UDP.UDPEndpoint
addEndpointMessageListener, close, getSocket, handleMessage, init, isClosed, isInputEndpoint, removeEndpointMessageListener, send, send
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UDPMulticastEndpoint

public UDPMulticastEndpoint(boolean discovery)
                     throws java.io.IOException
Creates a multicast socket attached to a new port


UDPMulticastEndpoint

public UDPMulticastEndpoint(java.lang.String groupaddr,
                            int port)
                     throws java.io.IOException
Creates a multicast socket attaches to the specified group address and port

Method Detail

initSocket

protected void initSocket(int port,
                          boolean input)
                   throws java.io.IOException
Initialises the socket

Overrides:
initSocket in class UDPEndpoint
Throws:
java.io.IOException

getEndpointURI

public java.net.URI getEndpointURI()
Specified by:
getEndpointURI in interface Endpoint
Overrides:
getEndpointURI in class UDPEndpoint
Returns:
the transport protocol for this socket

getSendURI

public java.net.URI getSendURI()
Specified by:
getSendURI in interface Endpoint
Overrides:
getSendURI in class UDPEndpoint
Returns:
the address being sent to by this endpoint (if known)

isOutputEndpoint

public boolean isOutputEndpoint()
Specified by:
isOutputEndpoint in interface Endpoint
Overrides:
isOutputEndpoint in class UDPEndpoint
Returns:
true if this endpoint is output enabled

send

public void send(byte[] message)
          throws java.io.IOException
Sends a message from the endpoint to the address the endpoint is bound to, with no sendid.

Specified by:
send in interface Endpoint
Overrides:
send in class UDPEndpoint
Throws:
java.io.IOException

send

public void send(java.lang.String sendid,
                 byte[] message)
          throws java.io.IOException
Sends a message from the endpoint to the address the endpoint is bound to, along with the send id for this message.

Specified by:
send in interface Endpoint
Overrides:
send in class UDPEndpoint
Throws:
java.io.IOException