Class TcpMessage
Helpers for generating TCP messages.
Inherited Members
Namespace: Akka.IO
Assembly: Akka.dll
Syntax
public static class TcpMessage
Methods
| Edit this page View SourceAbort()
Aborts a TCP connection without flushing pending writes.
Declaration
public static Tcp.Command Abort()
Returns
| Type | Description |
|---|---|
| Tcp.Command |
Bind(IActorRef, EndPoint, int)
Bind a TCP listener to a local endpoint.
Declaration
public static Tcp.Command Bind(IActorRef handler, EndPoint endpoint, int backlog)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | handler | The actor who will be handling the TCP listener. |
| EndPoint | endpoint | The local endpoint we are binding to. |
| int | backlog | TCP backlog - the number of pending connections that the queue will hold. |
Returns
| Type | Description |
|---|---|
| Tcp.Command |
Bind(IActorRef, EndPoint, int, IEnumerable<SocketOption>, bool)
Bind a TCP listener to a local endpoint.
Declaration
public static Tcp.Command Bind(IActorRef handler, EndPoint endpoint, int backlog, IEnumerable<Inet.SocketOption> options, bool pullMode)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | handler | The actor who will be handling the TCP listener. |
| EndPoint | endpoint | The local endpoint we are binding to. |
| int | backlog | TCP backlog - the number of pending connections that the queue will hold. |
| IEnumerable<Inet.SocketOption> | options | A set of socket options. |
| bool | pullMode | Specifies whether we're running in "pull mode" or not for all subsequent client connections. |
Returns
| Type | Description |
|---|---|
| Tcp.Command |
Close()
Closes an open TCP connection.
Declaration
public static Tcp.Command Close()
Returns
| Type | Description |
|---|---|
| Tcp.Command |
ConfirmedClose()
Closes a confirmed-to-have-been-previously-running TCP connection.
Declaration
public static Tcp.Command ConfirmedClose()
Returns
| Type | Description |
|---|---|
| Tcp.Command |
Connect(EndPoint)
Connect to a remote TCP endpoint.
Declaration
public static Tcp.Command Connect(EndPoint remoteAddress)
Parameters
| Type | Name | Description |
|---|---|---|
| EndPoint | remoteAddress | The remote endpoint |
Returns
| Type | Description |
|---|---|
| Tcp.Command |
Connect(EndPoint, EndPoint?, IEnumerable<SocketOption>, TimeSpan?, bool)
Connect to a remote TCP endpoint.
Declaration
public static Tcp.Command Connect(EndPoint remoteAddress, EndPoint? localAddress, IEnumerable<Inet.SocketOption> options, TimeSpan? timeout, bool pullMode)
Parameters
| Type | Name | Description |
|---|---|---|
| EndPoint | remoteAddress | The remote endpoint |
| EndPoint | localAddress | An optional local endpoint address to bind to. Most users don't specify this. |
| IEnumerable<Inet.SocketOption> | options | A set of socket options. |
| TimeSpan? | timeout | An optional connect timeout. Will result in a Tcp.CommandFailed message being returned if we exceed this value. |
| bool | pullMode | Specifies whether we're running in "pull mode" or not. |
Returns
| Type | Description |
|---|---|
| Tcp.Command |
NoAck(object?)
Creates a Tcp.NoAck instance indicating that no write acknowledgment is needed.
Declaration
public static Tcp.NoAck NoAck(object? token = null)
Parameters
| Type | Name | Description |
|---|---|---|
| object | token | An optional correlation token used to identify a specific write when receiving a Tcp.CommandFailed message. |
Returns
| Type | Description |
|---|---|
| Tcp.NoAck | A new Tcp.NoAck instance. |
Register(IActorRef, bool, bool)
Registers an actor to handle an outgoing or incoming TCP connection that has been established.
Declaration
public static Tcp.Command Register(IActorRef handler, bool keepOpenOnPeerClosed = false, bool useResumeWriting = true)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | handler | The actor who will be handling the TCP communication. |
| bool | keepOpenOnPeerClosed | Keep the connection open if the peer is closed |
| bool | useResumeWriting | Use resume / pause writing semantics once buffer gets full |
Returns
| Type | Description |
|---|---|
| Tcp.Command |
ResumeAccepting(int)
Creates a Tcp.ResumeAccepting command to resume accepting new connections when read throttling is enabled.
Declaration
public static Tcp.Command ResumeAccepting(int batchSize)
Parameters
| Type | Name | Description |
|---|---|---|
| int | batchSize | The number of connections to accept before pausing again. |
Returns
| Type | Description |
|---|---|
| Tcp.Command | A Tcp.Command that resumes accepting connections. |
ResumeReading()
Creates a Tcp.ResumeReading command to resume reading from the TCP socket after a Tcp.SuspendReading command.
Declaration
public static Tcp.Command ResumeReading()
Returns
| Type | Description |
|---|---|
| Tcp.Command | A Tcp.Command that resumes reading on the connection. |
ResumeWriting()
Creates a Tcp.ResumeWriting command to re-enable writing after a Tcp.CommandFailed event.
Declaration
public static Tcp.Command ResumeWriting()
Returns
| Type | Description |
|---|---|
| Tcp.Command | A Tcp.Command that resumes writing on the connection. |
SuspendReading()
Creates a Tcp.SuspendReading command to temporarily stop reading from the TCP socket.
Declaration
public static Tcp.Command SuspendReading()
Returns
| Type | Description |
|---|---|
| Tcp.Command | A Tcp.Command that suspends reading on the connection. |
Unbind()
Unbinds a previously bound TCP listener.
Declaration
public static Tcp.Command Unbind()
Returns
| Type | Description |
|---|---|
| Tcp.Command |
Write(byte[], Event?)
Creates a Tcp.Write command to send data over a TCP connection.
Declaration
public static Tcp.Command Write(byte[] data, Tcp.Event? ack = null)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | data | The data to write to the TCP connection. |
| Tcp.Event | ack | An optional acknowledgment event to be sent back when the write completes. If null, Tcp.NoAck is used. |
Returns
| Type | Description |
|---|---|
| Tcp.Command | A Tcp.Command representing the write operation. |
Write(ReadOnlyMemory<byte>, Event?)
Creates a Tcp.Write command to send data over a TCP connection.
Declaration
public static Tcp.Command Write(ReadOnlyMemory<byte> data, Tcp.Event? ack = null)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlyMemory<byte> | data | The data to write to the TCP connection. |
| Tcp.Event | ack | An optional acknowledgment event to be sent back when the write completes. If null, Tcp.NoAck is used. |
Returns
| Type | Description |
|---|---|
| Tcp.Command | A Tcp.Command representing the write operation. |
Edit this page