p2ps.endpoint
Interface Endpoint

All Known Subinterfaces:
ServerEndpoint, StreamEndpoint
All Known Implementing Classes:
TCPEndpoint, TCPInputEndpoint, UDPEndpoint, UDPReplyEndpoint

public interface Endpoint

The interface implemented by all endpoint classes

Version:
$Revision: 295 $
Author:
Ian Wang

Method Summary
 void addEndpointMessageListener(EndpointMessageListener listener)
          Adds a listener to receive data from this endpoint
 void close()
          Closes the endpoint.
 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.
 

Method Detail

init

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

Throws:
java.io.IOException

getEndpointURI

public java.net.URI getEndpointURI()
Returns:
the address of this endpoint

getSendURI

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

isInputEndpoint

public boolean isInputEndpoint()
Returns:
true if this endpoint is input enabled

isOutputEndpoint

public boolean isOutputEndpoint()
Returns:
true if this endpoint is output enabled

addEndpointMessageListener

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


removeEndpointMessageListener

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


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.

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.

Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Closes the endpoint. Note that the endpoint is not guaranteed closed until isClosed returns true.

Throws:
java.io.IOException

isClosed

public boolean isClosed()
Returns:
true if the endpoint is closed