monoio/net/
listener_config.rs1#[derive(Debug, Clone, Copy)]
3#[non_exhaustive]
4pub struct ListenerOpts {
5 pub reuse_port: bool,
7 pub reuse_addr: bool,
9 pub backlog: i32,
11 pub send_buf_size: Option<usize>,
13 pub recv_buf_size: Option<usize>,
15 pub tcp_fast_open: bool,
17}
18
19impl Default for ListenerOpts {
20 #[inline]
21 fn default() -> Self {
22 Self::new()
23 }
24}
25
26impl ListenerOpts {
27 #[inline]
29 pub const fn new() -> Self {
30 Self {
31 reuse_port: true,
32 reuse_addr: true,
33 backlog: 1024,
34 send_buf_size: None,
35 recv_buf_size: None,
36 tcp_fast_open: false,
37 }
38 }
39
40 #[must_use]
42 #[inline]
43 pub fn reuse_port(mut self, reuse_port: bool) -> Self {
44 self.reuse_port = reuse_port;
45 self
46 }
47
48 #[must_use]
50 #[inline]
51 pub fn reuse_addr(mut self, reuse_addr: bool) -> Self {
52 self.reuse_addr = reuse_addr;
53 self
54 }
55
56 #[must_use]
58 #[inline]
59 pub fn backlog(mut self, backlog: i32) -> Self {
60 self.backlog = backlog;
61 self
62 }
63
64 #[must_use]
66 #[inline]
67 pub fn send_buf_size(mut self, send_buf_size: usize) -> Self {
68 self.send_buf_size = Some(send_buf_size);
69 self
70 }
71
72 #[must_use]
74 #[inline]
75 pub fn recv_buf_size(mut self, recv_buf_size: usize) -> Self {
76 self.recv_buf_size = Some(recv_buf_size);
77 self
78 }
79
80 #[must_use]
86 #[inline]
87 pub fn tcp_fast_open(mut self, fast_open: bool) -> Self {
88 self.tcp_fast_open = fast_open;
89 self
90 }
91}