Refactored networking code

This commit is contained in:
Thorsten Sommer 2024-11-05 18:56:50 +01:00
parent 23bd11f4db
commit 45f0ab234f
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 9 additions and 6 deletions

View File

@ -1,3 +1,4 @@
pub mod encryption; pub mod encryption;
pub mod log; pub mod log;
pub mod environment; pub mod environment;
pub mod network;

View File

@ -517,11 +517,6 @@ async fn dotnet_ready(_token: APIToken) {
} }
} }
fn get_available_port() -> Option<u16> {
TcpListener::bind(("127.0.0.1", 0))
.map(|listener| listener.local_addr().unwrap().port())
.ok()
}
fn stop_servers() { fn stop_servers() {
if let Some(server_process) = DOTNET_SERVER.lock().unwrap().take() { if let Some(server_process) = DOTNET_SERVER.lock().unwrap().take() {

7
runtime/src/network.rs Normal file
View File

@ -0,0 +1,7 @@
use std::net::TcpListener;
pub fn get_available_port() -> Option<u16> {
TcpListener::bind(("127.0.0.1", 0))
.map(|listener| listener.local_addr().unwrap().port())
.ok()
}