MCPcopy Index your code
hub / github.com/NativeScript/SimDeck / connect_loopback_devtools_service

Function connect_loopback_devtools_service

packages/server/src/devtools.rs:499–517  ·  view source on GitHub ↗
(
    port: u16,
    timeout_duration: Duration,
    service_name: &str,
)

Source from the content-addressed store, hash-verified

497}
498
499async fn connect_loopback_devtools_service(
500 port: u16,
501 timeout_duration: Duration,
502 service_name: &str,
503) -> Result<(String, TcpStream), String> {
504 let mut errors = Vec::new();
505 for host in DEVTOOLS_DISCOVERY_HOSTS {
506 let address = format!("{host}:{port}");
507 match timeout(timeout_duration, TcpStream::connect(&address)).await {
508 Ok(Ok(stream)) => return Ok((address, stream)),
509 Ok(Err(error)) => errors.push(format!("{address}: {error}")),
510 Err(_) => errors.push(format!("{address}: timed out")),
511 }
512 }
513 Err(format!(
514 "Unable to connect to {service_name} on loopback port {port}: {}",
515 errors.join("; ")
516 ))
517}
518
519async fn candidate_devtools_ports() -> Vec<u16> {
520 let mut ports = BTreeSet::new();

Callers 1

fetch_metro_resourceFunction · 0.85

Calls 1

connectFunction · 0.50

Tested by

no test coverage detected