Package org.apache.pekko.io
Class TcpMessage$
java.lang.Object
org.apache.pekko.io.TcpMessage$
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TcpMessage$Static reference to the singleton instance of this Scala object. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabort()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.bind(ActorRef handler, InetSocketAddress endpoint, int backlog) Open a listening socket without specifying options.bind(ActorRef handler, InetSocketAddress endpoint, int backlog, Iterable<Inet.SocketOption> options, boolean pullMode) The Bind message is send to the TCP manager actor, which is obtained viaTcpExt.getManager()in order to bind to a listening socket.close()A normal close operation will first flush pending writes and then close the socket.A confirmed close operation will flush pending writes and half-close the connection, waiting for the peer to close the other half.connect(InetSocketAddress remoteAddress) Connect to the givenremoteAddresswithout binding to a local address and without specifying options.connect(InetSocketAddress remoteAddress, InetSocketAddress localAddress, Iterable<Inet.SocketOption> options, Duration timeout, boolean pullMode) The Connect message is sent to the TCP manager actor, which is obtained viaTcpExt.getManager().connect(InetSocketAddress remoteAddress, InetSocketAddress localAddress, Iterable<Inet.SocketOption> options, scala.concurrent.duration.FiniteDuration timeout, boolean pullMode) The Connect message is sent to the TCP manager actor, which is obtained viaTcpExt.getManager().noAck()DefaultTcp.NoAckinstance which is used when no acknowledgment information is explicitly provided.EachTcp.WriteCommandcan optionally request a positive acknowledgment to be sent to the commanding actor.The same asregister(handler, false, false).This message must be sent to a TCP connection actor after receiving theTcp.Connectedmessage.resumeAccepting(int batchSize) This message enables the accepting of the next connection if pull reading is enabled for connection actors.This command needs to be sent to the connection actor after aTcp.SuspendReadingcommand in order to resume reading from the socket.WhenuseResumeWritingis in effect as was indicated in theTcp.Registermessage then this command needs to be sent to the connection actor in order to re-enable writing after aTcp.CommandFailedevent.Sending this command to the connection actor will disable reading from the TCP socket.unbind()In order to close down a listening socket, send this message to that socket’s actor (that is the actor which previously had sent theTcp.Boundmessage).write(ByteString data) The same aswrite(data, noAck()).write(ByteString data, Tcp.Event ack) Write data to the TCP connection.Writecountbytes starting atpositionfrom file atfilePathto the connection.Writecountbytes starting atpositionfrom file atfilePathto the connection.
-
Field Details
-
MODULE$
Static reference to the singleton instance of this Scala object.
-
-
Constructor Details
-
TcpMessage$
public TcpMessage$()
-
-
Method Details
-
connect
public Tcp.Command connect(InetSocketAddress remoteAddress, InetSocketAddress localAddress, Iterable<Inet.SocketOption> options, scala.concurrent.duration.FiniteDuration timeout, boolean pullMode) The Connect message is sent to the TCP manager actor, which is obtained viaTcpExt.getManager(). Either the manager replies with aTcp.CommandFailedor the actor handling the new connection replies with aTcp.Connectedmessage.- Parameters:
remoteAddress- is the address to connect tolocalAddress- optionally specifies a specific address to bind tooptions- Please refer toTcpSOfor a list of all supported options.timeout- is the desired connection timeout,nullmeans "no timeout"pullMode- enables pull based reading from the connection
-
connect
public Tcp.Command connect(InetSocketAddress remoteAddress, InetSocketAddress localAddress, Iterable<Inet.SocketOption> options, Duration timeout, boolean pullMode) The Connect message is sent to the TCP manager actor, which is obtained viaTcpExt.getManager(). Either the manager replies with aTcp.CommandFailedor the actor handling the new connection replies with aTcp.Connectedmessage.- Parameters:
remoteAddress- is the address to connect tolocalAddress- optionally specifies a specific address to bind tooptions- Please refer toTcpSOfor a list of all supported options.timeout- is the desired connection timeout,nullmeans "no timeout"pullMode- enables pull based reading from the connection
-
connect
Connect to the givenremoteAddresswithout binding to a local address and without specifying options. -
bind
public Tcp.Command bind(ActorRef handler, InetSocketAddress endpoint, int backlog, Iterable<Inet.SocketOption> options, boolean pullMode) The Bind message is send to the TCP manager actor, which is obtained viaTcpExt.getManager()in order to bind to a listening socket. The manager replies either with aTcp.CommandFailedor the actor handling the listen socket replies with aTcp.Boundmessage. If the local port is set to 0 in the Bind message, then theTcp.Boundmessage should be inspected to find the actual port which was bound to.- Parameters:
handler- The actor which will receive all incoming connection requests in the form ofTcp.Connectedmessages.endpoint- The socket address to bind to; use port zero for automatic assignment (i.e. an ephemeral port, seeTcp.Bound)backlog- This specifies the number of unaccepted connections the O/S kernel will hold for this port before refusing connections.options- Please refer toTcpSOfor a list of all supported options.pullMode- enables pull based accepting and of connections and pull based reading from the accepted connections.
-
bind
Open a listening socket without specifying options. -
register
public Tcp.Command register(ActorRef handler, boolean keepOpenOnPeerClosed, boolean useResumeWriting) This message must be sent to a TCP connection actor after receiving theTcp.Connectedmessage. 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.- Parameters:
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 explicitTcp.ConnectionClosed from our side when finished.useResumeWriting- If this is set to true then the connection actor will refuse all further writes after issuing aTcp.CommandFailednotification untilTcpResumeWritingis received. This can be used to implement NACK-based write backpressure.
-
register
The same asregister(handler, false, false). -
unbind
In order to close down a listening socket, send this message to that socket’s actor (that is the actor which previously had sent theTcp.Boundmessage). The listener socket actor will reply with aTcp.Unboundmessage. -
close
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 aTcp.Closedmessage. -
confirmedClose
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 aTcp.ConfirmedClosedmessage. -
abort
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 aTcp.Abortedmessage. -
noAck
EachTcp.WriteCommandcan optionally request a positive acknowledgment to be sent to the commanding actor. If such notification is not desired theTcp.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 aTcp.CommandFailedmessage. -
noAck
DefaultTcp.NoAckinstance which is used when no acknowledgment information is explicitly provided. Its “token” isnull. -
write
Write data to the TCP connection. If no ack is needed use the specialNoAckobject. The connection actor will reply with aTcp.CommandFailedmessage if the write could not be enqueued. IfTcp.SimpleWriteCommand.wantsAck()returns true, the connection actor will reply with the suppliedTcp.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. -
write
The same aswrite(data, noAck()). -
writeFile
Writecountbytes starting atpositionfrom file atfilePathto the connection. The count must be > 0. The connection actor will reply with aTcp.CommandFailedmessage if the write could not be enqueued. IfTcp.SimpleWriteCommand.wantsAck()returns true, the connection actor will reply with the suppliedTcp.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. -
writePath
Writecountbytes starting atpositionfrom file atfilePathto the connection. The count must be > 0. The connection actor will reply with aTcp.CommandFailedmessage if the write could not be enqueued. IfTcp.SimpleWriteCommand.wantsAck()returns true, the connection actor will reply with the suppliedTcp.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. -
resumeWriting
WhenuseResumeWritingis in effect as was indicated in theTcp.Registermessage then this command needs to be sent to the connection actor in order to re-enable writing after aTcp.CommandFailedevent. AllTcp.WriteCommandprocessed by the connection actor between the firstTcp.CommandFailedand subsequent reception of this message will also be rejected withTcp.CommandFailed. -
suspendReading
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 sendTcp.ResumeReading. -
resumeReading
This command needs to be sent to the connection actor after aTcp.SuspendReadingcommand in order to resume reading from the socket. -
resumeAccepting
This message enables the accepting of the next connection if pull reading is enabled for connection actors.- Parameters:
batchSize- The number of connections to accept before waiting for the next resume command
-