本文簡要介紹rust語言中 std::net::UdpSocket.take_error
的用法。
用法
pub fn take_error(&self) -> Result<Option<Error>>
獲取此套接字上SO_ERROR
選項的值。
這將檢索底層套接字中存儲的錯誤,清除進程中的字段。這對於檢查調用之間的錯誤很有用。
例子
use std::net::UdpSocket;
let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address");
match socket.take_error() {
Ok(Some(error)) => println!("UdpSocket error: {:?}", error),
Ok(None) => println!("No error"),
Err(error) => println!("UdpSocket.take_error failed: {:?}", error),
}
相關用法
- Rust UdpSocket.ttl用法及代碼示例
- Rust UdpSocket.try_clone用法及代碼示例
- Rust UdpSocket.set_multicast_loop_v6用法及代碼示例
- Rust UdpSocket.send用法及代碼示例
- Rust UdpSocket.set_write_timeout用法及代碼示例
- Rust UdpSocket.peek用法及代碼示例
- Rust UdpSocket.set_ttl用法及代碼示例
- Rust UdpSocket.broadcast用法及代碼示例
- Rust UdpSocket.peer_addr用法及代碼示例
- Rust UdpSocket.set_broadcast用法及代碼示例
- Rust UdpSocket.send_to用法及代碼示例
- Rust UdpSocket.recv_from用法及代碼示例
- Rust UdpSocket.bind用法及代碼示例
- Rust UdpSocket.recv用法及代碼示例
- Rust UdpSocket.set_multicast_loop_v4用法及代碼示例
- Rust UdpSocket.write_timeout用法及代碼示例
- Rust UdpSocket.set_read_timeout用法及代碼示例
- Rust UdpSocket.set_nonblocking用法及代碼示例
- Rust UdpSocket.connect用法及代碼示例
- Rust UdpSocket.multicast_loop_v6用法及代碼示例
- Rust UdpSocket.read_timeout用法及代碼示例
- Rust UdpSocket.multicast_loop_v4用法及代碼示例
- Rust UdpSocket.peek_from用法及代碼示例
- Rust UdpSocket.multicast_ttl_v4用法及代碼示例
- Rust UdpSocket.set_multicast_ttl_v4用法及代碼示例
注:本文由純淨天空篩選整理自rust-lang.org大神的英文原創作品 std::net::UdpSocket.take_error。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。