o

akka.io

Tcp

object Tcp extends ExtensionId[TcpExt] with ExtensionIdProvider

TCP Extension for Akka’s IO layer.

For a full description of the design and philosophy behind this IO implementation please refer to the Akka online documentation.

In order to open an outbound connection send a Tcp.Connect message to the TcpExt#manager.

In order to start listening for inbound connections send a Tcp.Bind message to the TcpExt#manager.

The Java API for generating TCP commands is available at TcpMessage.

Source
Tcp.scala
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Tcp
  2. ExtensionIdProvider
  3. ExtensionId
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. final case class Bind(handler: ActorRef, localAddress: InetSocketAddress, backlog: Int = 100, options: Traversable[SocketOption] = Nil, pullMode: Boolean = false) extends Command with Product with Serializable

    The Bind message is send to the TCP manager actor, which is obtained via TcpExt#manager in order to bind to a listening socket.

    The Bind message is send to the TCP manager actor, which is obtained via TcpExt#manager in order to bind to a listening socket. The manager replies either with a CommandFailed or the actor handling the listen socket replies with a Bound message. If the local port is set to 0 in the Bind message, then the Bound message should be inspected to find the actual port which was bound to.

    handler

    The actor which will receive all incoming connection requests in the form of Connected messages.

    localAddress

    The socket address to bind to; use port zero for automatic assignment (i.e. an ephemeral port, see Bound)

    backlog

    This specifies the number of unaccepted connections the O/S kernel will hold for this port before refusing connections.

    options

    Please refer to the Tcp.SO object for a list of all supported options.

    Annotations
    @silent()
  2. final case class Bound(localAddress: InetSocketAddress) extends Event with Product with Serializable

    The sender of a Bind command will—in case of success—receive confirmation in this form.

    The sender of a Bind command will—in case of success—receive confirmation in this form. If the bind address indicated a 0 port number, then the contained localAddress can be used to find out which port was automatically assigned.

  3. sealed trait CloseCommand extends Command with DeadLetterSuppression

    Common interface for all commands which aim to close down an open connection.

  4. trait Command extends Message with HasFailureMessage

    This is the common trait for all commands understood by TCP actors.

  5. final case class CommandFailed(cmd: Command) extends Event with Product with Serializable

    Whenever a command cannot be completed, the queried actor will reply with this message, wrapping the original command which failed.

  6. final case class CompoundWrite(head: SimpleWriteCommand, tailCommand: WriteCommand) extends WriteCommand with Iterable[SimpleWriteCommand] with Product with Serializable

    A write command which aggregates two other write commands.

    A write command which aggregates two other write commands. Using this construct you can chain a number of Write and/or WriteFile commands together in a way that allows them to be handled as a single write which gets written out to the network as quickly as possible. If the sub commands contain ack requests they will be honored as soon as the respective write has been written completely.

  7. final case class Connect(remoteAddress: InetSocketAddress, localAddress: Option[InetSocketAddress] = None, options: Traversable[SocketOption] = Nil, timeout: Option[FiniteDuration] = None, pullMode: Boolean = false) extends Command with Product with Serializable

    The Connect message is sent to the TCP manager actor, which is obtained via TcpExt#manager.

    The Connect message is sent to the TCP manager actor, which is obtained via TcpExt#manager. Either the manager replies with a CommandFailed or the actor handling the new connection replies with a Connected message.

    remoteAddress

    is the address to connect to

    localAddress

    optionally specifies a specific address to bind to

    options

    Please refer to the Tcp.SO object for a list of all supported options.

    Annotations
    @silent()
  8. final case class Connected(remoteAddress: InetSocketAddress, localAddress: InetSocketAddress) extends Event with Product with Serializable

    The connection actor sends this message either to the sender of a Connect command (for outbound) or to the handler for incoming connections designated in the Bind message.

    The connection actor sends this message either to the sender of a Connect command (for outbound) or to the handler for incoming connections designated in the Bind message. The connection is characterized by the remoteAddress and localAddress TCP endpoints.

  9. sealed trait ConnectionClosed extends Event with DeadLetterSuppression

    This is the common interface for all events which indicate that a connection has been closed or half-closed.

  10. final case class ErrorClosed(cause: String) extends ConnectionClosed with Product with Serializable

    The connection has been closed due to an IO error.

  11. trait Event extends Message

    Common interface for all events generated by the TCP layer actors.

  12. sealed trait Message extends NoSerializationVerificationNeeded

    The common interface for Command and Event.

  13. case class NoAck(token: Any) extends Event with Product with Serializable

    Each WriteCommand can optionally request a positive acknowledgment to be sent to the commanding actor.

    Each WriteCommand can optionally request a positive acknowledgment to be sent to the commanding actor. If such notification is not desired the SimpleWriteCommand#ack must be set to an instance of this class. The token contained within can be used to recognize which write failed when receiving a CommandFailed message.

  14. final case class Received(data: ByteString) extends Event with Product with Serializable

    Whenever data are read from a socket they will be transferred within this class to the handler actor which was designated in the Register message.

  15. final case class Register(handler: ActorRef, keepOpenOnPeerClosed: Boolean = false, useResumeWriting: Boolean = true) extends Command with Product with Serializable

    This message must be sent to a TCP connection actor after receiving the Connected message.

    This message must be sent to a TCP connection actor after receiving the Connected message. The connection will not read any data from the socket until this message is received, because this message defines the actor which will receive all inbound data.

    handler

    The actor which will receive all incoming data and which will be informed when the connection is closed.

    keepOpenOnPeerClosed

    If this is set to true then the connection is not automatically closed when the peer closes its half, requiring an explicit CloseCommand from our side when finished.

    useResumeWriting

    If this is set to true then the connection actor will refuse all further writes after issuing a CommandFailed notification until ResumeWriting is received. This can be used to implement NACK-based write backpressure.

  16. final case class ResumeAccepting(batchSize: Int) extends Command with Product with Serializable

    This message enables the accepting of the next connection if read throttling is enabled for connection actors.

    This message enables the accepting of the next connection if read throttling is enabled for connection actors.

    batchSize

    The number of connections to accept before waiting for the next resume command

  17. sealed abstract class SimpleWriteCommand extends WriteCommand

    Common supertype of Write and WriteFile.

  18. sealed trait Unbound extends Event

    The sender of an Unbind command will receive confirmation through this message once the listening socket has been closed.

  19. final case class Write(data: ByteString, ack: Event) extends SimpleWriteCommand with Product with Serializable

    Write data to the TCP connection.

    Write data to the TCP connection. If no ack is needed use the special NoAck object. The connection actor will reply with a CommandFailed message if the write could not be enqueued. If SimpleWriteCommand#wantsAck returns true, the connection actor will reply with the supplied SimpleWriteCommand#ack token once the write has been successfully enqueued to the O/S kernel. Note that this does not in any way guarantee that the data will be or have been sent! Unfortunately there is no way to determine whether a particular write has been sent by the O/S.

  20. sealed abstract class WriteCommand extends Command

    Common interface for all write commands.

  21. final case class WritePath(path: Path, position: Long, count: Long, ack: Event) extends SimpleWriteCommand with Product with Serializable

    Write count bytes starting at position from file at filePath to the connection.

    Write count bytes starting at position from file at filePath to the connection. The count must be > 0. The connection actor will reply with a CommandFailed message if the write could not be enqueued. If SimpleWriteCommand#wantsAck returns true, the connection actor will reply with the supplied SimpleWriteCommand#ack token once the write has been successfully enqueued to the O/S kernel. Note that this does not in any way guarantee that the data will be or have been sent! Unfortunately there is no way to determine whether a particular write has been sent by the O/S.

  22. sealed trait WritingResumed extends Event

    When useResumeWriting is in effect as indicated in the Register message, the ResumeWriting command will be acknowledged by this message type, upon which it is safe to send at least one write.

    When useResumeWriting is in effect as indicated in the Register message, the ResumeWriting command will be acknowledged by this message type, upon which it is safe to send at least one write. This means that all writes preceding the first CommandFailed message have been enqueued to the O/S kernel at this point.

  23. final case class WriteFile(filePath: String, position: Long, count: Long, ack: Event) extends SimpleWriteCommand with Product with Serializable

    Annotations
    @deprecated
    Deprecated

    (Since version 2.5.10) Use WritePath instead

    See also

    WritePath

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def apply(system: ClassicActorSystemProvider): TcpExt

    Returns an instance of the extension identified by this ExtensionId instance.

    Returns an instance of the extension identified by this ExtensionId instance.

    Definition Classes
    ExtensionId
  5. def apply(system: ActorSystem): TcpExt

    Returns an instance of the extension identified by this ExtensionId instance.

    Returns an instance of the extension identified by this ExtensionId instance.

    Definition Classes
    ExtensionId
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate() @throws( ... )
  8. def createExtension(system: ExtendedActorSystem): TcpExt

    Is used by Akka to instantiate the Extension identified by this ExtensionId, internal use only.

    Is used by Akka to instantiate the Extension identified by this ExtensionId, internal use only.

    Definition Classes
    TcpExtensionId
  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. final def equals(other: Any): Boolean
    Definition Classes
    ExtensionId → AnyRef → Any
  11. def get(system: ClassicActorSystemProvider): TcpExt

    Returns an instance of the extension identified by this ExtensionId instance.

    Returns an instance of the extension identified by this ExtensionId instance. Java API For extensions written in Scala that are to be used from Java also, this method should be overridden to get correct return type.

    override def get(system: ClassicActorSystemProvider): TheExtension = super.get(system)
    Definition Classes
    TcpExtensionId
  12. def get(system: ActorSystem): TcpExt

    Java API: retrieve the Tcp extension for the given system.

    Java API: retrieve the Tcp extension for the given system.

    Definition Classes
    TcpExtensionId
  13. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  14. final def hashCode(): Int
    Definition Classes
    ExtensionId → AnyRef → Any
  15. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  16. def lookup(): Tcp.type

    Returns the canonical ExtensionId for this Extension

    Returns the canonical ExtensionId for this Extension

    Definition Classes
    TcpExtensionIdProvider
  17. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  18. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  19. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  20. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  21. def toString(): String
    Definition Classes
    AnyRef → Any
  22. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  24. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. object Abort extends CloseCommand with Product with Serializable

    An abort operation will not flush pending writes and will issue a TCP ABORT command to the O/S kernel which should result in a TCP_RST packet being sent to the peer.

    An abort operation will not flush pending writes and will issue a TCP ABORT command to the O/S kernel which should result in a TCP_RST packet being sent to the peer. The sender of this command and the registered handler for incoming data will both be notified once the socket is closed using a Aborted message.

  26. object Aborted extends ConnectionClosed with Product with Serializable

    The connection has been aborted in response to an Abort command.

  27. object Close extends CloseCommand with Product with Serializable

    A normal close operation will first flush pending writes and then close the socket.

    A normal close operation will first flush pending writes and then close the socket. The sender of this command and the registered handler for incoming data will both be notified once the socket is closed using a Closed message.

  28. object Closed extends ConnectionClosed with Product with Serializable

    The connection has been closed normally in response to a Close command.

  29. object ConfirmedClose extends CloseCommand with Product with Serializable

    A confirmed close operation will flush pending writes and half-close the connection, waiting for the peer to close the other half.

    A confirmed close operation will flush pending writes and half-close the connection, waiting for the peer to close the other half. The sender of this command and the registered handler for incoming data will both be notified once the socket is closed using a ConfirmedClosed message.

  30. object ConfirmedClosed extends ConnectionClosed with Product with Serializable

    The connection has been half-closed by us and then half-close by the peer in response to a ConfirmedClose command.

  31. object NoAck extends NoAck

    Default NoAck instance which is used when no acknowledgment information is explicitly provided.

    Default NoAck instance which is used when no acknowledgment information is explicitly provided. Its “token” is null.

  32. object PeerClosed extends ConnectionClosed with Product with Serializable

    The peer has closed its writing half of the connection.

  33. object ResumeReading extends Command with DeadLetterSuppression with Product with Serializable

    This command needs to be sent to the connection actor after a SuspendReading command in order to resume reading from the socket.

    This command needs to be sent to the connection actor after a SuspendReading command in order to resume reading from the socket.

    (This message is marked with DeadLetterSuppression as it is prone to end up in DeadLetters when the connection is torn down at the same time as the user wants to resume reading on that connection.)

  34. object ResumeWriting extends Command with Product with Serializable

    When useResumeWriting is in effect as was indicated in the Register message then this command needs to be sent to the connection actor in order to re-enable writing after a CommandFailed event.

    When useResumeWriting is in effect as was indicated in the Register message then this command needs to be sent to the connection actor in order to re-enable writing after a CommandFailed event. All WriteCommand processed by the connection actor between the first CommandFailed and subsequent reception of this message will also be rejected with CommandFailed.

  35. object SO extends SoForwarders

    Scala API: this object contains all applicable socket options for TCP.

    Scala API: this object contains all applicable socket options for TCP.

    For the Java API see TcpSO.

  36. object SuspendReading extends Command with Product with Serializable

    Sending this command to the connection actor will disable reading from the TCP socket.

    Sending this command to the connection actor will disable reading from the TCP socket. TCP flow-control will then propagate backpressure to the sender side as buffers fill up on either end. To re-enable reading send ResumeReading.

  37. object Unbind extends Command with Product with Serializable

    In order to close down a listening socket, send this message to that socket’s actor (that is the actor which previously had sent the Bound message).

    In order to close down a listening socket, send this message to that socket’s actor (that is the actor which previously had sent the Bound message). The listener socket actor will reply with a Unbound message.

  38. object Unbound extends Unbound with Product with Serializable
  39. object Write extends Serializable
  40. object WriteCommand
  41. object WritingResumed extends WritingResumed with Product with Serializable

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @Deprecated @deprecated @throws( classOf[java.lang.Throwable] )
    Deprecated

    (Since version ) see corresponding Javadoc for more information.

Inherited from ExtensionIdProvider

Inherited from ExtensionId[TcpExt]

Inherited from AnyRef

Inherited from Any

Ungrouped