p2ps.imp.endpoint.UDP
Class UDPReplyEndpoint

java.lang.Object
  extended byp2ps.imp.endpoint.UDP.UDPReplyEndpoint
All Implemented Interfaces:
Endpoint

public class UDPReplyEndpoint
extends java.lang.Object
implements Endpoint

An wrapper endpoint that is used to reply to a specific UDP network address.

Version:
$Revision: 295 $
Author:
Ian Wang

Constructor Summary
UDPReplyEndpoint(UDPEndpoint endpoint)
           
 
Method Summary
 void addEndpointMessageListener(EndpointMessageListener listener)
          Adds a listener to receive data from this endpoint
 void close()
          Closes the endpoint
 void connect(java.net.SocketAddress address)
          Connects the socket to the specified address
 void connect(java.lang.String address, int port)
          Connects the socket to the specified address
 java.net.URI getEndpointURI()
           
 java.net.URI getSendURI()
           
 void init()
          initializes the endpoint
 boolean isClosed()
           
 boolean isInputEndpoint()
           
 boolean isOutputEndpoint()
           
 void removeEndpointMessageListener(EndpointMessageListener listener)
          Removes a listener from this endpoint
 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UDPReplyEndpoint

public UDPReplyEndpoint(UDPEndpoint endpoint)
Parameters:
endpoint - the endpoint this reply endpoint wraps
Method Detail

init

public void init()
          throws java.io.IOException
initializes the endpoint

Specified by:
init in interface Endpoint
Throws:
java.io.IOException

addEndpointMessageListener

public void addEndpointMessageListener(EndpointMessageListener listener)
Adds a listener to receive data from this endpoint

Specified by:
addEndpointMessageListener in interface Endpoint

removeEndpointMessageListener

public void removeEndpointMessageListener(EndpointMessageListener listener)
Removes a listener from this endpoint

Specified by:
removeEndpointMessageListener in interface Endpoint

getEndpointURI

public java.net.URI getEndpointURI()
Specified by:
getEndpointURI in interface Endpoint
Returns:
the address of this endpoint

getSendURI

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

isInputEndpoint

public boolean isInputEndpoint()
Specified by:
isInputEndpoint in interface Endpoint
Returns:
true if this endpoint is input enabled

isOutputEndpoint

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

connect

public void connect(java.lang.String address,
                    int port)
Connects the socket to the specified address


connect

public void connect(java.net.SocketAddress address)
Connects the socket to the specified address


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
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
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Closes the endpoint

Specified by:
close in interface Endpoint
Throws:
java.io.IOException

isClosed

public boolean isClosed()
Specified by:
isClosed in interface Endpoint
Returns:
true if the endpoint is closed