本文簡要介紹rust語言中 Struct std::os::unix::net::UnixDatagram
的用法。
用法
pub struct UnixDatagram(_);
一個 Unix 數據報套接字。
例子
use std::os::unix::net::UnixDatagram;
fn main() -> std::io::Result<()> {
let socket = UnixDatagram::bind("/path/to/my/socket")?;
socket.send_to(b"hello world", "/path/to/other/socket")?;
let mut buf = [0; 100];
let (count, address) = socket.recv_from(&mut buf)?;
println!("socket {:?} sent {:?}", address, &buf[..count]);
Ok(())
}
相關用法
- Rust UnixDatagram.peek_from用法及代碼示例
- Rust UnixDatagram.recv_from用法及代碼示例
- Rust UnixDatagram.take_error用法及代碼示例
- Rust UnixDatagram.peek用法及代碼示例
- Rust UnixDatagram.send_to_addr用法及代碼示例
- Rust UnixDatagram.read_timeout用法及代碼示例
- Rust UnixDatagram.set_nonblocking用法及代碼示例
- Rust UnixDatagram.connect用法及代碼示例
- Rust UnixDatagram.set_read_timeout用法及代碼示例
- Rust UnixDatagram.send_to用法及代碼示例
- Rust UnixDatagram.shutdown用法及代碼示例
- Rust UnixDatagram.set_passcred用法及代碼示例
- Rust UnixDatagram.recv_vectored_with_ancillary用法及代碼示例
- Rust UnixDatagram.recv_vectored_with_ancillary_from用法及代碼示例
- Rust UnixDatagram.bind_addr用法及代碼示例
- Rust UnixDatagram.send_vectored_with_ancillary_to用法及代碼示例
- Rust UnixDatagram.try_clone用法及代碼示例
- Rust UnixDatagram.send用法及代碼示例
- Rust UnixDatagram.bind用法及代碼示例
- Rust UnixDatagram.write_timeout用法及代碼示例
- Rust UnixDatagram.recv用法及代碼示例
- Rust UnixDatagram.connect_addr用法及代碼示例
- Rust UnixDatagram.peer_addr用法及代碼示例
- Rust UnixDatagram.pair用法及代碼示例
- Rust UnixDatagram.set_write_timeout用法及代碼示例
注:本文由純淨天空篩選整理自rust-lang.org大神的英文原創作品 Struct std::os::unix::net::UnixDatagram。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。