• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //! Network-related operations.
2 //!
3 //! On Windows, one must call [`wsa_startup`] in the process before calling any
4 //! of these APIs. [`wsa_cleanup`] may be used in the process if these APIs are
5 //! no longer needed.
6 //!
7 //! [`wsa_startup`]: https://docs.rs/rustix/latest/x86_64-pc-windows-msvc/rustix/net/fn.wsa_startup.html
8 //! [`wsa_cleanup`]: https://docs.rs/rustix/latest/x86_64-pc-windows-msvc/rustix/net/fn.wsa_cleanup.html
9 
10 #[cfg(not(feature = "std"))]
11 mod addr;
12 #[cfg(not(feature = "std"))]
13 mod ip;
14 mod send_recv;
15 mod socket;
16 mod socket_addr_any;
17 #[cfg(not(any(windows, target_os = "wasi")))]
18 mod socketpair;
19 #[cfg(windows)]
20 mod wsa;
21 
22 pub mod sockopt;
23 
24 pub use send_recv::{
25     recv, recvfrom, send, sendto, sendto_any, sendto_v4, sendto_v6, RecvFlags, SendFlags,
26 };
27 pub use socket::{
28     accept, accept_with, acceptfrom, acceptfrom_with, bind, bind_any, bind_v4, bind_v6, connect,
29     connect_any, connect_v4, connect_v6, getpeername, getsockname, listen, shutdown, socket,
30     socket_with, AcceptFlags, AddressFamily, Protocol, Shutdown, SocketFlags, SocketType,
31 };
32 pub use socket_addr_any::{SocketAddrAny, SocketAddrStorage};
33 #[cfg(not(any(windows, target_os = "wasi")))]
34 pub use socketpair::socketpair;
35 #[cfg(feature = "std")]
36 pub use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
37 #[cfg(windows)]
38 pub use wsa::{wsa_cleanup, wsa_startup};
39 #[cfg(not(feature = "std"))]
40 pub use {
41     addr::{SocketAddr, SocketAddrV4, SocketAddrV6},
42     ip::{IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope},
43 };
44 #[cfg(unix)]
45 pub use {
46     send_recv::sendto_unix,
47     socket::{bind_unix, connect_unix, SocketAddrUnix},
48 };
49