com.aelitis.azureus.core.networkmanager.impl.tcp
Class TCPTransportImpl

java.lang.Object
  extended by com.aelitis.azureus.core.networkmanager.impl.TransportImpl
      extended by com.aelitis.azureus.core.networkmanager.impl.tcp.TCPTransportImpl
All Implemented Interfaces:
Transport, TransportBase

public class TCPTransportImpl
extends TransportImpl
implements Transport

Represents a peer TCP transport connection (eg. a network socket).


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.aelitis.azureus.core.networkmanager.Transport
Transport.ConnectListener
 
Field Summary
 boolean has_been_closed
           
 
Fields inherited from interface com.aelitis.azureus.core.networkmanager.Transport
TRANSPORT_MODE_FAST, TRANSPORT_MODE_NORMAL, TRANSPORT_MODE_TURBO
 
Constructor Summary
TCPTransportImpl(ProtocolEndpointTCP endpoint, boolean use_crypto, boolean allow_fallback, byte[][] _shared_secrets)
          Constructor for disconnected (outbound) transport.
TCPTransportImpl(ProtocolEndpointTCP endpoint, TransportHelperFilter filter)
          Constructor for connected (inbound) transport.
 
Method Summary
 void close(String reason)
          Close the transport connection.
protected  void close(TransportHelper helper, String reason)
           
protected  void connectedOutbound(ByteBuffer remaining_initial_data, Transport.ConnectListener listener)
           
 void connectOutbound(ByteBuffer initial_data, Transport.ConnectListener listener, int priority)
          Request the transport connection be established.
 String getDescription()
          Get a textual description for this transport.
 int getMssSize()
           
 String getProtocol()
           
 SocketChannel getSocketChannel()
          Get the socket channel used by the transport.
 TransportEndpointTCP getTransportEndpoint()
          Get the socket channel used by the transport.
 int getTransportMode()
          Get the transport's speed mode.
 TransportStartpoint getTransportStartpoint()
           
protected  void handleCrypto(InetSocketAddress address, SocketChannel channel, ByteBuffer initial_data, int priority, Transport.ConnectListener listener)
           
 boolean isSOCKS()
           
 boolean isTCP()
           
 void setTransportMode(int mode)
          Set the transport to the given speed mode.
 
Methods inherited from class com.aelitis.azureus.core.networkmanager.impl.TransportImpl
bindConnection, connectedInbound, connectedOutbound, getEncryption, getFilter, isEncrypted, isReadyForRead, isReadyForWrite, read, readFailed, readyForRead, readyForWrite, setAlreadyRead, setFilter, setReadyForRead, setTrace, unbindConnection, write, writeFailed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.aelitis.azureus.core.networkmanager.Transport
bindConnection, connectedInbound, getEncryption, isEncrypted, read, setAlreadyRead, setReadyForRead, setTrace, unbindConnection, write
 
Methods inherited from interface com.aelitis.azureus.core.networkmanager.TransportBase
isReadyForRead, isReadyForWrite
 

Field Detail

has_been_closed

public volatile boolean has_been_closed
Constructor Detail

TCPTransportImpl

public TCPTransportImpl(ProtocolEndpointTCP endpoint,
                        boolean use_crypto,
                        boolean allow_fallback,
                        byte[][] _shared_secrets)
Constructor for disconnected (outbound) transport.


TCPTransportImpl

public TCPTransportImpl(ProtocolEndpointTCP endpoint,
                        TransportHelperFilter filter)
Constructor for connected (inbound) transport.

Parameters:
channel - connection
already_read - bytes from the channel
Method Detail

getSocketChannel

public SocketChannel getSocketChannel()
Get the socket channel used by the transport.

Returns:
the socket channel

getTransportEndpoint

public TransportEndpointTCP getTransportEndpoint()
Description copied from interface: Transport
Get the socket channel used by the transport.

Specified by:
getTransportEndpoint in interface Transport
Returns:
the socket channel

getTransportStartpoint

public TransportStartpoint getTransportStartpoint()
Specified by:
getTransportStartpoint in interface Transport
Overrides:
getTransportStartpoint in class TransportImpl

getMssSize

public int getMssSize()
Specified by:
getMssSize in interface Transport

isTCP

public boolean isTCP()
Specified by:
isTCP in interface TransportBase

isSOCKS

public boolean isSOCKS()
Specified by:
isSOCKS in interface Transport
Overrides:
isSOCKS in class TransportImpl

getProtocol

public String getProtocol()
Specified by:
getProtocol in interface Transport
Overrides:
getProtocol in class TransportImpl

getDescription

public String getDescription()
Get a textual description for this transport.

Specified by:
getDescription in interface TransportBase
Returns:
description

connectOutbound

public void connectOutbound(ByteBuffer initial_data,
                            Transport.ConnectListener listener,
                            int priority)
Request the transport connection be established. NOTE: Will automatically connect via configured proxy if necessary.

Specified by:
connectOutbound in interface Transport
Parameters:
address - remote peer address to connect to
listener - establishment failure/success listener

handleCrypto

protected void handleCrypto(InetSocketAddress address,
                            SocketChannel channel,
                            ByteBuffer initial_data,
                            int priority,
                            Transport.ConnectListener listener)

setTransportMode

public void setTransportMode(int mode)
Set the transport to the given speed mode.

Specified by:
setTransportMode in interface Transport
Parameters:
mode - to change to

connectedOutbound

protected void connectedOutbound(ByteBuffer remaining_initial_data,
                                 Transport.ConnectListener listener)

getTransportMode

public int getTransportMode()
Get the transport's speed mode.

Specified by:
getTransportMode in interface Transport
Returns:
current mode

close

protected void close(TransportHelper helper,
                     String reason)

close

public void close(String reason)
Close the transport connection.

Specified by:
close in interface Transport