What do you mean?
Binding is not any different if you use high / low level DSLs (that’s the
routing DSL vs. just matching incoming objects).

The difference is in the binding call you can do, there’s a few styles, yet
each gives back a binding, which contains an address:

val bindingFuture = Http().bindAndHandle(routes, interface =
"0.0.0.0", port = 8080)
bindingFuture.foreach { binding ⇒
  println(s"Server online at ${binding.localAddress}")
}


val source = Http().bind(interface = "0.0.0.0", port = 8080)
val bindingFuture2 = source.to(Sink.foreach {
  conn ⇒ conn.handleWith(routes)
}).run()
bindingFuture2.foreach { binding ⇒
  println(s"Server online at ${binding.localAddress}")
}


-- 
Cheers,
Konrad 'ktoso <http://kto.so>' Malawski
Akka <http://akka.io/> @ Lightbend <http://lightbend.com/>

On March 7, 2018 at 4:20:39, Alan Burlison (alan.burli...@gmail.com) wrote:

The Akka HTTP documentation [1] says:

"The Http.ServerBinding also provides a way to get a hold of the actual
local address of the bound socket, which is useful for example when
binding to port zero (and thus letting the OS pick an available port)."

The scenario is I'm using a localhost http service which needs to be on
a system-assigned localhost port to communicate with subprocesses and I
need to find out which port the server is bound to. Despite what the
documentation says I can find no way of doing this before starting to
accept incoming connections, and no way of doing it using the high-level
routing DSL.

[1]
https://doc.akka.io/docs/akka-http/current/server-side/low-level-api.html#starting-and-stopping

-- 
Alan Burlison
-- 

-- 
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups
"Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to