I want to send textual messages over TCP. Pretty easy. I want to do so with akka. I read this article about akka IO: http://doc.akka.io/docs/akka/snapshot/scala/io-tcp.html
The article present a simple implementation of a TCP client, but it's not clear to me how I would use this client.
The constructor takes an InetSocketAddress and an ActorRef. InetSocketAddress make sense (I assume this is the of the destination) but what's the ActorRef? this is my first time using akka, but from what I understand, ActorRef is the reference of another actor. Since my TCP client is an actor, and I expect this TCP actor to communicate with a TCP server, not with another actor, why would I give it an actor ref?
what's the props function in the companion object for?
once instantiated, how would I use this actor to send TCP messages? Should I just send it a message with the data I want to send in the form of a ByteString?
4. what's the connection / difference between
case Received(data) =>
listener ! data
and
case data: ByteString =>
connection ! Write(data)