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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// ---------------- [ File: bitcoin-sock/src/compat.rs ]
crateix!;
pub const WSAENOTSOCK: c_int = EBADF;
pub const SOCKET_ERROR: c_int = -1;
pub type sockopt_arg_type = *mut c_void;
pub type sockopt_arg_type = *mut u8;
/**
| Note these both should work with the current
| usage of poll, but best to be safe WIN32 poll
| is broken
| https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/
| __APPLE__ poll is broke
| https://github.com/bitcoin/bitcoin/pull/14336#issuecomment-437384408
*/
pub const USE_POLL: bool = true;
/*
#[cfg(not(target_os = "windows"))]
pub const INVALID_SOCKET: CSocket = !0;
/// Native Windows `SOCKET` handle (always `usize`‑sized).
#[cfg(target_os = "windows")]
pub type CSocket = usize;
/// POSIX file‑descriptor representing a socket.
#[cfg(not(target_os = "windows"))]
pub type CSocket = libc::c_int;
*/
/// Determine whether the socket `s` can safely be
/// used with `select(2)` on the current platform.
///
/// * On Windows **or** when the build is configured
/// with `USE_POLL`, every socket is considered
/// selectable (mirrors the original C++ logic).
/// * On Unix builds that rely on classic `select(2)`
/// we ensure the descriptor is `< FD_SETSIZE`.