Package com.biglybt.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
Nested Classes Modifier and Type Interface Description static interface
Transport.ConnectListener
Listener for notification of connection establishment.
-
Field Summary
Fields Modifier and Type Field Description static int
TRANSPORT_MODE_FAST
static int
TRANSPORT_MODE_NORMAL
static int
TRANSPORT_MODE_TURBO
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
bindConnection(NetworkConnection connection)
void
close(java.lang.String reason)
Close the transport connection.void
connectedInbound()
Indicate that inbound connection is completevoid
connectOutbound(java.nio.ByteBuffer initial_data, Transport.ConnectListener listener, int priority)
Kick off an outbound connectionjava.lang.String
getEncryption(boolean verbose)
Return a textual description of the encryption for this transportint
getMssSize()
java.lang.String
getProtocol()
TransportEndpoint
getTransportEndpoint()
Get the socket channel used by the transport.int
getTransportMode()
Get the transport's speed mode.TransportStartpoint
getTransportStartpoint()
java.lang.Object
getUserData(java.lang.Object key)
boolean
isEncrypted()
boolean
isSOCKS()
long
read(java.nio.ByteBuffer[] buffers, int array_offset, int length)
Read data from the transport into the given buffers.void
setAlreadyRead(java.nio.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 attemptedvoid
setTrace(boolean on)
void
setTransportMode(int mode)
Set the transport to the given speed mode.void
setUserData(java.lang.Object key, java.lang.Object value)
void
unbindConnection(NetworkConnection connection)
long
write(java.nio.ByteBuffer[] buffers, int array_offset, int length)
Write data to the transport from the given buffers.-
Methods inherited from interface com.biglybt.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(java.nio.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
java.lang.String getEncryption(boolean verbose)
Return a textual description of the encryption for this transport- Returns:
-
getProtocol
java.lang.String getProtocol()
-
isSOCKS
boolean isSOCKS()
-
setReadyForRead
void setReadyForRead()
fake a wakeup so that a read cycle is attempted
-
write
long write(java.nio.ByteBuffer[] buffers, int array_offset, int length) throws java.io.IOException
Write data to the transport from the given buffers. NOTE: Works like GatheringByteChannel.- Parameters:
buffers
- from which bytes are to be retrievedarray_offset
- offset within the buffer array of the first buffer from which bytes are to be retrievedlength
- maximum number of buffers to be accessed- Returns:
- number of bytes written
- Throws:
java.io.IOException
- on write error
-
read
long read(java.nio.ByteBuffer[] buffers, int array_offset, int length) throws java.io.IOException
Read data from the transport into the given buffers. NOTE: Works like ScatteringByteChannel.- Parameters:
buffers
- into which bytes are to be placedarray_offset
- offset within the buffer array of the first buffer into which bytes are to be placedlength
- maximum number of buffers to be accessed- Returns:
- number of bytes read
- Throws:
java.io.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(java.nio.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(java.lang.String reason)
Close the transport connection.
-
bindConnection
void bindConnection(NetworkConnection connection)
-
unbindConnection
void unbindConnection(NetworkConnection connection)
-
getUserData
java.lang.Object getUserData(java.lang.Object key)
-
setUserData
void setUserData(java.lang.Object key, java.lang.Object value)
-
setTrace
void setTrace(boolean on)
-
-