com.aelitis.azureus.core.networkmanager.impl
Class TransportImpl

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

public abstract class TransportImpl
extends Object
implements Transport


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.aelitis.azureus.core.networkmanager.Transport
Transport.ConnectListener
 
Field Summary
 
Fields inherited from interface com.aelitis.azureus.core.networkmanager.Transport
TRANSPORT_MODE_FAST, TRANSPORT_MODE_NORMAL, TRANSPORT_MODE_TURBO
 
Constructor Summary
protected TransportImpl()
           
 
Method Summary
 void bindConnection(NetworkConnection connection)
           
 void connectedInbound()
          Indicate that inbound connection is complete
 void connectedOutbound()
           
 String getEncryption(boolean verbose)
          Return a textual description of the encryption for this transport
 TransportHelperFilter getFilter()
           
 String getProtocol()
           
 TransportStartpoint getTransportStartpoint()
           
 boolean isEncrypted()
           
 long isReadyForRead(EventWaiter waiter)
          Is the transport ready to read, i.e.
 boolean isReadyForWrite(EventWaiter waiter)
          Is the transport ready to write, i.e.
 boolean isSOCKS()
           
 long read(ByteBuffer[] buffers, int array_offset, int length)
          Read data from the transport into the given buffers.
protected  void readFailed(Throwable msg)
           
protected  boolean readyForRead(boolean ready)
           
protected  boolean readyForWrite(boolean ready)
           
 void setAlreadyRead(ByteBuffer bytes_already_read)
          Inject the given already-read data back into the read stream.
 void setFilter(TransportHelperFilter _filter)
           
 void setReadyForRead()
          fake a wakeup so that a read cycle is attempted
 void setTrace(boolean on)
           
 void unbindConnection(NetworkConnection connection)
           
 long write(ByteBuffer[] buffers, int array_offset, int length)
          Write data to the transport from the given buffers.
protected  void writeFailed(Throwable msg)
           
 
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
close, connectOutbound, getMssSize, getTransportEndpoint, getTransportMode, setTransportMode
 
Methods inherited from interface com.aelitis.azureus.core.networkmanager.TransportBase
getDescription, isTCP
 

Constructor Detail

TransportImpl

protected TransportImpl()
Method Detail

getTransportStartpoint

public TransportStartpoint getTransportStartpoint()
Specified by:
getTransportStartpoint in interface Transport

setFilter

public void setFilter(TransportHelperFilter _filter)

getFilter

public TransportHelperFilter getFilter()

setAlreadyRead

public void setAlreadyRead(ByteBuffer bytes_already_read)
Description copied from interface: Transport
Inject the given already-read data back into the read stream.

Specified by:
setAlreadyRead in interface Transport
Parameters:
bytes_already_read - data

getEncryption

public String getEncryption(boolean verbose)
Description copied from interface: Transport
Return a textual description of the encryption for this transport

Specified by:
getEncryption in interface Transport
Returns:

getProtocol

public String getProtocol()
Specified by:
getProtocol in interface Transport

isEncrypted

public boolean isEncrypted()
Specified by:
isEncrypted in interface Transport

isSOCKS

public boolean isSOCKS()
Specified by:
isSOCKS in interface Transport

isReadyForWrite

public boolean isReadyForWrite(EventWaiter waiter)
Is the transport ready to write, i.e. will a write request result in >0 bytes written.

Specified by:
isReadyForWrite in interface TransportBase
Returns:
true if the transport is write ready, false if not yet ready

readyForWrite

protected boolean readyForWrite(boolean ready)

writeFailed

protected void writeFailed(Throwable msg)

isReadyForRead

public long isReadyForRead(EventWaiter waiter)
Is the transport ready to read, i.e. will a read request result in >0 bytes read.

Specified by:
isReadyForRead in interface TransportBase
Returns:
0 if the transport is read ready, millis since last ready or -1 if never ready

readyForRead

protected boolean readyForRead(boolean ready)

setReadyForRead

public void setReadyForRead()
Description copied from interface: Transport
fake a wakeup so that a read cycle is attempted

Specified by:
setReadyForRead in interface Transport

readFailed

protected void readFailed(Throwable msg)

write

public long write(ByteBuffer[] buffers,
                  int array_offset,
                  int length)
           throws IOException
Write data to the transport from the given buffers. NOTE: Works like GatheringByteChannel.

Specified by:
write in interface Transport
Parameters:
buffers - from which bytes are to be retrieved
array_offset - offset within the buffer array of the first buffer from which bytes are to be retrieved
length - maximum number of buffers to be accessed
Returns:
number of bytes written
Throws:
IOException - on write error

read

public long read(ByteBuffer[] buffers,
                 int array_offset,
                 int length)
          throws IOException
Read data from the transport into the given buffers. NOTE: Works like ScatteringByteChannel.

Specified by:
read in interface Transport
Parameters:
buffers - into which bytes are to be placed
array_offset - offset within the buffer array of the first buffer into which bytes are to be placed
length - maximum number of buffers to be accessed
Returns:
number of bytes read
Throws:
IOException - on read error

connectedInbound

public void connectedInbound()
Description copied from interface: Transport
Indicate that inbound connection is complete

Specified by:
connectedInbound in interface Transport

connectedOutbound

public void connectedOutbound()

bindConnection

public void bindConnection(NetworkConnection connection)
Specified by:
bindConnection in interface Transport

unbindConnection

public void unbindConnection(NetworkConnection connection)
Specified by:
unbindConnection in interface Transport

setTrace

public void setTrace(boolean on)
Specified by:
setTrace in interface Transport