Packages

package tcp

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. tcp
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. final case class BufferSettings(packetBufferBaseSize: Int, packetStorageProvider: StorageProvider, readBufferSize: Int, readStorageProvider: StorageProvider) extends Product with Serializable

    packetBufferBaseSize

    the size of the packet buffer

    packetStorageProvider

    the provider of the packet buffer

    readBufferSize

    the size of the read buffer, used when there's a BytesTransform

    readStorageProvider

    the provider of the read buffer, used when there's a BytesTransform

  2. final case class Bytes(array: Array[Byte], length: Int) extends Product with Serializable

    array

    an array containing the data, starting at index 0

    length

    the length of the data

  3. type BytesTransform = (Bytes) ⇒ Bytes
  4. final class CipherTransform extends BytesTransform

    A transformation function that encrypts or decrypts data with a Cipher.

  5. trait ClientAttach[A <: ClientAttach[A]] extends AnyRef

    Stores data associated to one TCP client.

    Stores data associated to one TCP client. This abstract class provides basic reading and writing functionnality. Additionnal information and features may be added by the subclasses.

    Thread-safety

    • The public methods of ClientAttach may be called from any thread without problem.
    • The protected methods are called from the Selector thread. In particular, HAttach.readHeader and ClientAttach.handleData don't need to be thread-safe.
    • The completion handlers are run on the Selector thread. Therefore they should NOT perform long computations. If you have long computations to do, send them to an ExecutorService or something similar.
  6. abstract class HAttach[A <: HAttach[A]] extends ClientAttach[A]

    An implementation of ClientAttach that processes packets that are prefixed by a header (hence the H in HAttach).

    An implementation of ClientAttach that processes packets that are prefixed by a header (hence the H in HAttach).

    A

    generic parameter

  7. final class ScalableSelector extends Runnable

    A ScalableSelector uses one NIO Selector to handle many TCP connections on several ports with only one thread.

    A ScalableSelector uses one NIO Selector to handle many TCP connections on several ports with only one thread.

    Port listening

    To start listening for connections on a port, call the ScalableSelector.listen method.

    One (and only one) TcpListener is assigned for each port. When a new client connects to the port, the listener's TcpListener.onAccept method is called. It creates an instance of ClientAttach for the new client. The ClientAttach will handle the data received from the client and sent to the client.

    Buffer providers and sizes

    If there is no data transformation in the ClientAttach, the incoming data will be read in a (generally) low-level off-heap buffer provided by the readBufferProvider. The minimum size of the buffer will be packetBufferBaseSize.

    If there is a data transformation in the ClientAttach, the incoming data will still be read in a buffer provided by the readBufferProvider, but with a fixed size equal to preTransformReadSize. The read data is then transformed by the transformation function. Once the transformation is done, the packets are reconstructed in an other buffer of minimum size packetBufferBaseSize and provided by postTransformBufferProvider.

    The packet buffer's minimum size

    The incoming packets arrive in several parts. One part can contain several packets, and one packet can be split into different parts. Therefore they need to be reconstructed in a packet buffer. To avoid the allocation of a new buffer each time some data is read, a minimum "base" buffer is kept during the while connection. When the incoming packet is larger than the base buffer, an additional buffer is allocated, providing the missing capacity. Once the big packet is handled, the additional buffer is discarded.

  8. final class ServerChannelInfos[A <: ClientAttach[A]] extends AnyRef

    Contains the informations attached to a ServerSocketChannel that is registered to a ScalableSelector.

    Contains the informations attached to a ServerSocketChannel that is registered to a ScalableSelector.

    See also

    ScalableSelector

  9. trait TcpListener[A <: ClientAttach[A]] extends AnyRef

Value Members

  1. object BufferSettings extends Serializable
  2. object CipherTransform

Inherited from AnyRef

Inherited from Any

Ungrouped