Networking - เครือข่าย
std::net สำหรับ TCP/UDP networking และจัดการ IP addresses! เป็น module ที่ใช้สร้าง network applications ใน Rust
net มีอะไร?
Section titled “net มีอะไร?”- TCP:
TcpListener,TcpStream- connection-oriented - UDP:
UdpSocket- connectionless - IP:
IpAddr,Ipv4Addr,Ipv6Addr- IP addresses - Socket:
SocketAddr- IP + Port
Synchronous vs Async
Section titled “Synchronous vs Async”fn main() { // ============================================ // std::net เป็น synchronous (blocking) // ============================================
// - ง่ายต่อการเรียนรู้ // - เหมาะกับงานง่ายๆ หรือ multi-threaded server
// ============================================ // สำหรับ high-performance async ใช้: // ============================================
// - tokio: runtime ที่ popular ที่สุด // - async-std: compatible กับ std API // - mio: low-level event-driven I/O
println!("std::net = synchronous networking"); println!("For async, use tokio or async-std");}เข้าสู่ระบบเพื่อดูเนื้อหาเต็ม
ยืนยันตัวตนด้วยบัญชี Google เพื่อปลดล็อกบทความทั้งหมด
Login with Google