Refactor current net codes

This commit is contained in:
Jianfeng Jiang
2023-07-31 19:22:33 +08:00
committed by Tate, Hongliang Tian
parent f6b327dbda
commit ddb7be9296
24 changed files with 185 additions and 410 deletions

View File

@ -6,6 +6,7 @@ pub use self::util::sock_options::{SockOptionLevel, SockOptionName};
pub use self::util::sockaddr::SocketAddr;
pub mod ip;
pub mod unix;
mod util;
/// Operations defined on a socket.

View File

@ -13,3 +13,13 @@ pub enum SockShutdownCmd {
/// Shutdown receptions and transmissions
SHUT_RDWR = 2,
}
impl SockShutdownCmd {
pub fn shut_read(&self) -> bool {
*self == Self::SHUT_RD || *self == Self::SHUT_RDWR
}
pub fn shut_write(&self) -> bool {
*self == Self::SHUT_WR || *self == Self::SHUT_RDWR
}
}

View File

@ -6,7 +6,7 @@ type PortNum = u16;
#[derive(Debug)]
pub enum SocketAddr {
Unix,
Unix(String),
IPv4(Ipv4Address, PortNum),
IPv6,
}