diff --git a/src/build/run.cr b/src/build/run.cr index 0bbf523..f95591c 100644 --- a/src/build/run.cr +++ b/src/build/run.cr @@ -1,6 +1,7 @@ require "path" require "file_utils" +require "socket" require "./module" require "./config" @@ -38,7 +39,12 @@ module DocMachine::Build end private def _port_available?(port) - true + sock = Socket.new(Socket::Family::INET, Socket::Type::STREAM) + sock.bind(Socket::IPAddress.new("0.0.0.0", port)) + sock.close + return true + rescue ex : Socket::BindError + return false end private def _avoid_duplicates