Low-level, cross-platform RAII wrapper and utilities for raw OS sockets, mirroring Bitcoin Core networking semantics (send/recv, timeouts, readiness, error classification).
// ---------------- [ File: bitcoin-sock/src/lib.rs ]
#[macro_use]modimports;useimports::*;x!{sock}x!{io_error_is_permanent}x!{interface}x!{network_error_string}x!{is_connected}x!{recv_until_terminator}x!{send_complete}x!{wait}x!{close_socket}x!{compat}x!{lifetime}x!{last_socket_error}x!{compute_bounded_wait}#[cfg(test)]pub(crate)modtest_serial{useonce_cell::sync::Lazy;useparking_lot::Mutex;/// Global lock to serialize socket-using tests that would otherwise be flaky
/// due to process-global FD reuse.
pubstaticFD_LOCK:Lazy<Mutex<()>>=Lazy::new(||Mutex::new(()));}/// Helper macro for tests that should not run concurrently with other socket tests.
#[cfg(test)]#[macro_export]macro_rules!serialize_fds{()=>{let _fd_guard =$crate::test_serial::FD_LOCK.lock();// non-poisoning
};}