1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use crateError;
use crateAddressFamilyFlags;
use crateProtocolFlags;
use crateSocketInfo;
use crate*;
/// Collects sockets into a `Vec` using the provided filters.
///
/// This is a convenience wrapper around [`iter_sockets`](crate::iter_sockets) for callers
/// that prefer an eagerly collected result.
///
/// # Parameters
/// - `af_flags`: Address family filters (for example, IPv4 and/or IPv6).
/// - `proto_flags`: Protocol filters (TCP and/or UDP).
///
/// # Returns
/// A `Result<Vec<SocketInfo>, Error>`.
///
/// # Errors
/// Returns an error if socket enumeration fails.
///
/// # Examples
/// ```
/// use netsock::family::AddressFamilyFlags;
/// use netsock::get_sockets;
/// use netsock::protocol::ProtocolFlags;
///
/// let af_flags = AddressFamilyFlags::IPV4 | AddressFamilyFlags::IPV6;
/// let proto_flags = ProtocolFlags::TCP | ProtocolFlags::UDP;
///
/// match get_sockets(af_flags, proto_flags) {
/// Ok(sockets) => {
/// for socket in sockets {
/// println!("Socket: {:?}", socket);
/// }
/// },
/// Err(e) => eprintln!("Failed to get sockets: {}", e),
/// }
/// ```