diff --git a/veilid-core/src/intf/native/network_interfaces/apple.rs b/veilid-core/src/intf/native/network_interfaces/apple.rs index c643b2ad..b0c21ee1 100644 --- a/veilid-core/src/intf/native/network_interfaces/apple.rs +++ b/veilid-core/src/intf/native/network_interfaces/apple.rs @@ -468,7 +468,7 @@ impl PlatformSupportApple { ) { Ok(v) => v, Err(e) => { - log_net!(error "{}", e); + log_net!(error "failed to get address flags: {}", e); continue; } }; diff --git a/veilid-core/src/network_manager/native/network_class_discovery.rs b/veilid-core/src/network_manager/native/network_class_discovery.rs index 378ab5d6..02905bf9 100644 --- a/veilid-core/src/network_manager/native/network_class_discovery.rs +++ b/veilid-core/src/network_manager/native/network_class_discovery.rs @@ -704,7 +704,7 @@ impl Network { } } - // Do TCPv4 + WSv4 in series because they may use the same connection 5-tuple + // Do TCPv4. Possibly do WSv4 if it is on a different port if protocol_config.family_global.contains(AddressType::IPV4) { if protocol_config.inbound.contains(ProtocolType::TCP) { futures.push( @@ -747,7 +747,7 @@ impl Network { } } - // Do TCPv6 + WSv6 in series because they may use the same connection 5-tuple + // Do TCPv6. Possibly do WSv6 if it is on a different port if protocol_config.family_global.contains(AddressType::IPV6) { if protocol_config.inbound.contains(ProtocolType::TCP) { futures.push( diff --git a/veilid-core/src/network_manager/native/protocol/sockets.rs b/veilid-core/src/network_manager/native/protocol/sockets.rs index 71ee5676..5750513e 100644 --- a/veilid-core/src/network_manager/native/protocol/sockets.rs +++ b/veilid-core/src/network_manager/native/protocol/sockets.rs @@ -95,6 +95,18 @@ pub fn new_bound_first_udp_socket(local_address: SocketAddr) -> io::Result io::Result { + let socket = Socket::new(domain, Type::STREAM, Some(Protocol::TCP))?; + if let Err(e) = socket.set_nodelay(true) { + log_net!(error "Couldn't set TCP nodelay: {}", e); + } + if domain == Domain::IPV6 { + socket.set_only_v6(true)?; + } + Ok(socket) +} + #[instrument(level = "trace", ret)] pub fn new_unbound_shared_tcp_socket(domain: Domain) -> io::Result { let socket = Socket::new(domain, Type::STREAM, Some(Protocol::TCP))?; diff --git a/veilid-core/src/network_manager/native/protocol/tcp.rs b/veilid-core/src/network_manager/native/protocol/tcp.rs index c82fc04d..f095441f 100644 --- a/veilid-core/src/network_manager/native/protocol/tcp.rs +++ b/veilid-core/src/network_manager/native/protocol/tcp.rs @@ -162,7 +162,7 @@ impl RawTcpProtocolHandler { // Make a shared socket let socket = match local_address { Some(a) => new_bound_shared_tcp_socket(a)?, - None => new_unbound_shared_tcp_socket(socket2::Domain::for_address(socket_addr))?, + None => new_unbound_tcp_socket(socket2::Domain::for_address(socket_addr))?, }; // Non-blocking connect to remote address diff --git a/veilid-core/src/network_manager/native/protocol/ws.rs b/veilid-core/src/network_manager/native/protocol/ws.rs index ab421193..39c48de7 100644 --- a/veilid-core/src/network_manager/native/protocol/ws.rs +++ b/veilid-core/src/network_manager/native/protocol/ws.rs @@ -246,9 +246,7 @@ impl WebsocketProtocolHandler { // Make a shared socket let socket = match local_address { Some(a) => new_bound_shared_tcp_socket(a)?, - None => { - new_unbound_shared_tcp_socket(socket2::Domain::for_address(remote_socket_addr))? - } + None => new_unbound_tcp_socket(socket2::Domain::for_address(remote_socket_addr))?, }; // Non-blocking connect to remote address diff --git a/veilid-core/src/network_manager/network_connection.rs b/veilid-core/src/network_manager/network_connection.rs index 333ae677..4f532838 100644 --- a/veilid-core/src/network_manager/network_connection.rs +++ b/veilid-core/src/network_manager/network_connection.rs @@ -323,7 +323,7 @@ impl NetworkConnection { } Err(e) => { // Connection unable to receive, closed - log_net!(error e); + log_net!(error "connection unable to receive: {}", e); RecvLoopAction::Finish } } diff --git a/veilid-tools/src/network_result.rs b/veilid-tools/src/network_result.rs index ef782a1c..ae93fe97 100644 --- a/veilid-tools/src/network_result.rs +++ b/veilid-tools/src/network_result.rs @@ -31,7 +31,8 @@ impl IoNetworkResultExt for io::Result { #[cfg(feature = "io_error_more")] Err(e) => match e.kind() { io::ErrorKind::TimedOut => Ok(NetworkResult::Timeout), - io::ErrorKind::ConnectionAborted + io::ErrorKind::UnexpectedEof + | io::ErrorKind::ConnectionAborted | io::ErrorKind::ConnectionRefused | io::ErrorKind::ConnectionReset | io::ErrorKind::HostUnreachable @@ -49,7 +50,8 @@ impl IoNetworkResultExt for io::Result { } match e.kind() { io::ErrorKind::TimedOut => Ok(NetworkResult::Timeout), - io::ErrorKind::ConnectionAborted + io::ErrorKind::UnexpectedEof + | io::ErrorKind::ConnectionAborted | io::ErrorKind::ConnectionRefused | io::ErrorKind::ConnectionReset => Ok(NetworkResult::NoConnection(e)), io::ErrorKind::AddrNotAvailable => Ok(NetworkResult::AlreadyExists(e)),