mirror of
https://github.com/Noratrieb/survey.git
synced 2026-01-14 08:30:12 +01:00
nice
This commit is contained in:
parent
398a2dc2d6
commit
19e43ea5a2
2 changed files with 14 additions and 2 deletions
|
|
@ -1,2 +1,2 @@
|
|||
# survey
|
||||
epoll(7) things for fun and profit
|
||||
low level linux io
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use std::{
|
|||
io::{Read, Write},
|
||||
mem,
|
||||
mem::MaybeUninit,
|
||||
os::unix,
|
||||
os::{unix, unix::io::RawFd},
|
||||
};
|
||||
|
||||
const SOCKADDR_IN_SIZE: libc::socklen_t = mem::size_of::<libc::sockaddr_in>() as _;
|
||||
|
|
@ -87,6 +87,12 @@ impl Debug for SyncTcpListener {
|
|||
}
|
||||
}
|
||||
|
||||
impl unix::io::AsRawFd for SyncTcpListener {
|
||||
fn as_raw_fd(&self) -> RawFd {
|
||||
self.fd
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SyncTcpStream {
|
||||
fd: unix::io::RawFd,
|
||||
peer_sockaddr: libc::sockaddr_in,
|
||||
|
|
@ -134,6 +140,12 @@ impl Debug for SyncTcpStream {
|
|||
}
|
||||
}
|
||||
|
||||
impl unix::io::AsRawFd for SyncTcpStream {
|
||||
fn as_raw_fd(&self) -> RawFd {
|
||||
self.fd
|
||||
}
|
||||
}
|
||||
|
||||
fn format_addr(addr: libc::sockaddr_in) -> String {
|
||||
let bytes = addr.sin_addr.s_addr.to_be_bytes();
|
||||
format!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue