final class Tcp extends Extension
- Alphabetic
- By Inheritance
- Tcp
- Extension
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
- new Tcp(system: ExtendedActorSystem)
Value Members
-
def
bind(interface: String, port: Int, backlog: Int = 100, options: Traversable[SocketOption] = Nil, halfClose: Boolean = false, idleTimeout: Duration = Duration.Inf): Source[IncomingConnection, Future[ServerBinding]]
Creates a Tcp.ServerBinding instance which represents a prospective TCP server binding on the given
endpoint
.Creates a Tcp.ServerBinding instance which represents a prospective TCP server binding on the given
endpoint
.Please note that the startup of the server is asynchronous, i.e. after materializing the enclosing akka.stream.scaladsl.RunnableGraph the server is not immediately available. Only after the materialized future completes is the server ready to accept client connections.
- interface
The interface to listen on
- port
The port to listen on
- backlog
Controls the size of the connection backlog
- options
TCP options for the connections, see akka.io.Tcp for details
- halfClose
Controls whether the connection is kept open even after writing has been completed to the accepted TCP connections. If set to true, the connection will implement the TCP half-close mechanism, allowing the client to write to the connection even after the server has finished writing. The TCP socket is only closed after both the client and server finished writing. If set to false, the connection will immediately closed once the server closes its write side, independently whether the client is still attempting to write. This setting is recommended for servers, and therefore it is the default setting.
-
def
bindAndHandle(handler: Flow[ByteString, ByteString, _], interface: String, port: Int, backlog: Int = 100, options: Traversable[SocketOption] = Nil, halfClose: Boolean = false, idleTimeout: Duration = Duration.Inf)(implicit m: Materializer): Future[ServerBinding]
Creates a Tcp.ServerBinding instance which represents a prospective TCP server binding on the given
endpoint
handling the incoming connections using the provided Flow.Creates a Tcp.ServerBinding instance which represents a prospective TCP server binding on the given
endpoint
handling the incoming connections using the provided Flow.Please note that the startup of the server is asynchronous, i.e. after materializing the enclosing akka.stream.scaladsl.RunnableGraph the server is not immediately available. Only after the returned future completes is the server ready to accept client connections.
- handler
A Flow that represents the server logic
- interface
The interface to listen on
- port
The port to listen on
- backlog
Controls the size of the connection backlog
- options
TCP options for the connections, see akka.io.Tcp for details
- halfClose
Controls whether the connection is kept open even after writing has been completed to the accepted TCP connections. If set to true, the connection will implement the TCP half-close mechanism, allowing the client to write to the connection even after the server has finished writing. The TCP socket is only closed after both the client and server finished writing. If set to false, the connection will immediately closed once the server closes its write side, independently whether the client is still attempting to write. This setting is recommended for servers, and therefore it is the default setting.
- val bindShutdownTimeout: FiniteDuration
-
def
outgoingConnection(host: String, port: Int): Flow[ByteString, ByteString, Future[OutgoingConnection]]
Creates an Tcp.OutgoingConnection without specifying options.
Creates an Tcp.OutgoingConnection without specifying options. It represents a prospective TCP client connection to the given endpoint.
-
def
outgoingConnection(remoteAddress: InetSocketAddress, localAddress: Option[InetSocketAddress] = None, options: Traversable[SocketOption] = Nil, halfClose: Boolean = true, connectTimeout: Duration = Duration.Inf, idleTimeout: Duration = Duration.Inf): Flow[ByteString, ByteString, Future[OutgoingConnection]]
Creates an Tcp.OutgoingConnection instance representing a prospective TCP client connection to the given endpoint.
Creates an Tcp.OutgoingConnection instance representing a prospective TCP client connection to the given endpoint.
- remoteAddress
The remote address to connect to
- localAddress
Optional local address for the connection
- options
TCP options for the connections, see akka.io.Tcp for details
- halfClose
Controls whether the connection is kept open even after writing has been completed to the accepted TCP connections. If set to true, the connection will implement the TCP half-close mechanism, allowing the server to write to the connection even after the client has finished writing. The TCP socket is only closed after both the client and server finished writing. This setting is recommended for clients and therefore it is the default setting. If set to false, the connection will immediately closed once the client closes its write side, independently whether the server is still attempting to write.