MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / pick_free_port

Function pick_free_port

tests/common/mod.rs:374–383  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

372}
373
374pub fn pick_free_port() -> u16 {
375 let listener = match TcpListener::bind("127.0.0.1:0") {
376 Ok(listener) => listener,
377 Err(err) => panic!("failed to bind free local port: {err}"),
378 };
379 match listener.local_addr() {
380 Ok(addr) => addr.port(),
381 Err(err) => panic!("failed to read bound local address: {err}"),
382 }
383}
384
385pub fn http_agent() -> ureq::Agent {
386 http_agent_with_timeout(Duration::from_secs(4))

Calls

no outgoing calls