From 28a398d9f9ff762885a31307ee6373732d150136 Mon Sep 17 00:00:00 2001 From: iGxnon Date: Sat, 16 Nov 2024 23:36:10 +0800 Subject: [PATCH] remove client connect Signed-off-by: iGxnon --- src/client/conn/tokio.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/client/conn/tokio.rs b/src/client/conn/tokio.rs index df221ef..965fd3a 100644 --- a/src/client/conn/tokio.rs +++ b/src/client/conn/tokio.rs @@ -30,18 +30,9 @@ impl ConnectTo for TokioUdpSocket { )> { let socket = Arc::new(self); let mut lookups = addrs.to_socket_addrs()?; - let addr = loop { - if let Some(addr) = lookups.next() { - if socket.connect(addr).await.is_ok() { - break addr; - } - continue; - } - return Err(io::Error::new( - io::ErrorKind::AddrNotAvailable, - "invalid address", - )); - }; + let addr = lookups + .next() + .ok_or_else(|| io::Error::new(io::ErrorKind::AddrNotAvailable, "invalid address"))?; let (mut incoming, peer) = OfflineHandler::new( Framed::new(Arc::clone(&socket), config.mtu as usize), // TODO: discover MTU