com.aelitis.azureus.core.networkmanager
Interface Transport

All Superinterfaces:
TransportBase
All Known Implementing Classes:
LightweightTCPTransport, NetworkConnectionImpl.bogusTransport, TCPTransportImpl, TransportImpl, UDPTransport

public interface Transport
extends TransportBase

Represents a peer Transport connection (eg. a network socket).


Nested Class Summary
static interface Transport.ConnectListener
          Listener for notification of connection establishment.
 
Field Summary
static int TRANSPORT_MODE_FAST
           
static int TRANSPORT_MODE_NORMAL
           
static int TRANSPORT_MODE_TURBO
           
 
Method Summary
 void bindConnection(NetworkConnection connection)
           
 void close(String reason)
          Close the transport connection.
 void connectedInbound()
          Indicate that inbound connection is complete
 void connectOutbound(ByteBuffer initial_data, Transport.ConnectListener listener, int priority)
          Kick off an outbound connection
 String getEncryption(boolean verbose)
          Return a textual description of the encryption for this transport
 int getMssSize()
           
 String getProtocol()
           
 TransportEndpoint getTransportEndpoint()
          Get the socket channel used by the transport.
 int getTransportMode()
          Get the transport's speed mode.
 TransportStartpoint getTransportStartpoint()
           
 boolean isEncrypted()
           
 boolean isSOCKS()
           
 long read(ByteBuffer[] buffers, int array_offset, int length)
          Read data from the transport into the given buffers.
 void setAlreadyRead(ByteBuffer bytes_already_read)
          Inject the given already-read data back into the read stream.
 void setReadyForRead()
          fake a wakeup so that a read cycle is attempted
 void setTrace(boolean on)
           
 void setTransportMode(int mode)
          Set the transport to the given speed mode.
 void unbindConnection(NetworkConnection connection)
           
 long write(ByteBuffer[] buffers, int array_offset, int length)
          Write data to the transport from the given buffers.
 
Methods inherited from interface com.aelitis.azureus.core.networkmanager.TransportBase
getDescription, isReadyForRead, isReadyForWrite, isTCP
 

Field Detail

TRANSPORT_MODE_NORMAL

static final int TRANSPORT_MODE_NORMAL
See Also:
Constant Field Values

TRANSPORT_MODE_FAST

static final int TRANSPORT_MODE_FAST
See Also:
Constant Field Values

TRANSPORT_MODE_TURBO

static final int TRANSPORT_MODE_TURBO
See Also:
Constant Field Values
Method Detail

getMssSize

int getMssSize()

setAlreadyRead

void setAlreadyRead(ByteBuffer bytes_already_read)
Inject the given already-read data back into the read stream.

Parameters:
bytes_already_read - data

getTransportStartpoint

TransportStartpoint getTransportStartpoint()

getTransportEndpoint

TransportEndpoint getTransportEndpoint()
Get the socket channel used by the transport.

Returns:
the socket channel

isEncrypted

boolean isEncrypted()

getEncryption

String getEncryption(boolean verbose)
Return a textual description of the encryption for this transport

Returns:

getProtocol

String getProtocol()

isSOCKS

boolean isSOCKS()

setReadyForRead

void setReadyForRead()
fake a wakeup so that a read cycle is attempted


write

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

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

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

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

setTransportMode

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

Parameters:
mode - to change to

getTransportMode

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

Returns:
current mode

connectOutbound

void connectOutbound(ByteBuffer initial_data,
                     Transport.ConnectListener listener,
                     int priority)
Kick off an outbound connection

Parameters:
listener -

connectedInbound

void connectedInbound()
Indicate that inbound connection is complete


close

void close(String reason)
Close the transport connection.


bindConnection

void bindConnection(NetworkConnection connection)

unbindConnection

void unbindConnection(NetworkConnection connection)

setTrace

void setTrace(boolean on)