mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-02-11 14:49:07 +00:00
8 lines
243 B
Rust
8 lines
243 B
Rust
|
use std::net::TcpListener;
|
||
|
|
||
|
/// Returns an available port on the local machine.
|
||
|
pub fn get_available_port() -> Option<u16> {
|
||
|
TcpListener::bind(("127.0.0.1", 0))
|
||
|
.map(|listener| listener.local_addr().unwrap().port())
|
||
|
.ok()
|
||
|
}
|