I am dealing with a server for a rather picky protocol (SIP) that needs my local IP and port as part of the header structure. I am using an Akka TCP stream for its awesomeness but I am missing the equivalent of BSD socket's getsockname
function. In Akka actor-oriented connections, the connection sends a convenient message reporting the local IP and port, but I cannot find a way to get this from the Akka Streams version. The stream is connected directly to some flow for further processing, but there is no room for a message containing the IP and port of the local side of the connection.
val connection = Tcp().outgoingConnection("www.google.com", 80)
val test = List("GET / HTTP/1.1", "Host: www.google.com", "\r\n").map(s ⇒ ByteString(s + "\r\n"))
val res = Source(test).via(connection).runFold(ByteString.empty)( _ ++ _ )
// How do I get the connection details here?
res.onComplete{
case Success(resp) ⇒ println(resp.utf8String)
case Failure(f) ⇒ println(f)
}
Any ideas?