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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//! # Unix
//! The constructors every Unix socket task is started from
use crate;
use Path;
/// Talks to other programs on this machine over Unix sockets
///
/// It doesn't implement `Task`, so a method has to be called on
/// it to get something that does
///
/// ## Behaviour
/// A Unix socket is addressed by a path rather than a host and
/// port. [`Unix::connect`] and [`Unix::listen`] are the stream
/// kind, which behaves exactly like TCP and hands out the same
/// send and receive tasks. [`Unix::bind`] is the datagram kind,
/// which behaves like UDP
///
/// ```no_run
/// # use atap::{Runtime, unix::Unix};
/// # fn main() -> Result<(), atap::RuntimeError> {
/// let listener = Runtime::block(Unix::listen("/tmp/app.sock"))?;
/// let conn = Runtime::block(Unix::connect("/tmp/app.sock"))?;
/// let served = Runtime::block(listener.accept())?;
/// # Ok(())
/// # }
/// ```
///
/// ## Paths
/// A path can be at most 103 bytes, which is all the kernel has
/// room for. A longer one, an empty one, or one with a zero byte
/// in it gives [`RuntimeError::BadPath`]
///
/// A socket bound to a path makes a file there, and removes it
/// again once the last handle to the socket goes
///
/// ## Waiting
/// A spawned task waiting on a Unix socket holds no thread, the
/// same as a TCP one
///
/// [`RuntimeError::BadPath`]: crate::RuntimeError::BadPath
;