Skip to content

Commit

Permalink
Detect running server (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
spetz authored Nov 7, 2023
1 parent b46b75e commit b4005c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bench/src/server_starter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use integration::test_server::{TestServer, Transport, SYSTEM_PATH_ENV_VAR};
use serde::Deserialize;
use std::net::SocketAddr;
use std::{collections::HashMap, time::Instant};
use tokio::net::{TcpListener, UdpSocket};
use tokio::net::{TcpStream, UdpSocket};
use tracing::{info, warn};

#[derive(Debug, Deserialize)]
Expand Down Expand Up @@ -123,7 +123,7 @@ pub async fn start_server_if_needed(args: &mut IggyBenchArgs) -> Option<TestServ
}

async fn is_tcp_addr_in_use(addr: &SocketAddr) -> bool {
TcpListener::bind(addr).await.is_err()
TcpStream::connect(addr).await.is_ok()
}

async fn is_udp_addr_in_use(addr: &SocketAddr) -> bool {
Expand Down

0 comments on commit b4005c4

Please sign in to comment.