Project JXTA

net.jxta.impl.endpoint.tcp
Class TcpConnection

java.lang.Object
  extended bynet.jxta.impl.endpoint.tcp.TcpConnection
All Implemented Interfaces:
Runnable

class TcpConnection
extends Object
implements Runnable

Low-level TcpMessenger


Constructor Summary
(package private) TcpConnection(EndpointAddress destaddr, TcpTransport p)
          Creates a new TcpConnection for the specified destination address.
(package private) TcpConnection(Socket incSocket, TcpTransport p)
          Creates a new connection from an incoming socket
 
Method Summary
 void close()
          Soft close of the connection.
 boolean equals(Object target)
          
protected  void finalize()
          
 EndpointAddress getConnectionAddress()
           
 EndpointAddress getDestinationAddress()
           
 ID getDestinationPeerID()
           
 long getLastUsed()
          Return the absolute time in milliseconds at which this Connection was last used.
(package private)  TransportBindingMeter getTransportBindingMeter()
           
 int hashCode()
          
 boolean isConnected()
          return the current connection status.
 void run()
           This is the background Thread.
 void sendMessage(Message msg)
          Send message to the remote peer.
protected  void start()
           
 String toString()
          

Implementation for debugging.

 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TcpConnection

TcpConnection(EndpointAddress destaddr,
              TcpTransport p)
        throws IOException
Creates a new TcpConnection for the specified destination address.

Parameters:
destaddr - the destination address of this connection.
p - the transport which this connection is part of.
Throws:
IOException - for failures in creating the connection.

TcpConnection

TcpConnection(Socket incSocket,
              TcpTransport p)
        throws IOException
Creates a new connection from an incoming socket

Parameters:
incSocket - the incoming socket.
Throws:
IOException - for failures in creating the connection.
Method Detail

equals

public boolean equals(Object target)


finalize

protected void finalize()


hashCode

public int hashCode()


toString

public String toString()

Implementation for debugging.


getDestinationAddress

public EndpointAddress getDestinationAddress()

getConnectionAddress

public EndpointAddress getConnectionAddress()

getDestinationPeerID

public ID getDestinationPeerID()

start

protected void start()

sendMessage

public void sendMessage(Message msg)
                 throws IOException
Send message to the remote peer.

Parameters:
msg - the message to send.
Throws:
IOException

run

public void run()
This is the background Thread. While the connection is active, takes messages from the queue and send it.

Specified by:
run in interface Runnable

close

public void close()
Soft close of the connection. Messages can no longer be sent, but any in the queue will be flushed.


isConnected

public boolean isConnected()
return the current connection status.


getLastUsed

public long getLastUsed()
Return the absolute time in milliseconds at which this Connection was last used.

Returns:
absolute time in milliseconds.

getTransportBindingMeter

TransportBindingMeter getTransportBindingMeter()

JXTA J2SE