When starting a server with port = 0, is there a w...
# ktor
m
When starting a server with port = 0, is there a way to tell what random port it ends up binding to?
d
Right now it is not possible. I created a branch adding support for it, but requires reviewing, and maybe doing it other way: https://github.com/ktorio/ktor/compare/enable-available-port
m
startAndGetBindings()
seems like exactly what i want. Not only will it wait until the sockets are open (perfect!), it gives me the data I need to use them. 🙂
Exposing port directly (via the cast from SocketAddress) works fine in my case but doesn’t fit if the hope is ot eventually support things like unix sockets.
Perhaps a sealed class of binding types for different engines might be appropriate? Or maybe YAGNI. Not sure if ktor is ever meant to support things beyond TCP, but it seems like it would be nice to not close the door on that
d
Yeah. Not sure. It is only a proposal. Sot sure about further plans on that
m
either way you’re 2 for 2 on creepily having already built the features I need 😉
simple smile 1