當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Rust UdpSocket.write_timeout用法及代碼示例

本文簡要介紹rust語言中 std::net::UdpSocket.write_timeout 的用法。

用法

pub fn write_timeout(&self) -> Result<Option<Duration>>

返回此套接字的寫入超時。

如果超時為 None ,則 write 調用將無限期阻塞。

例子

use std::net::UdpSocket;

let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address");
socket.set_write_timeout(None).expect("set_write_timeout call failed");
assert_eq!(socket.write_timeout().unwrap(), None);

相關用法


注:本文由純淨天空篩選整理自rust-lang.org大神的英文原創作品 std::net::UdpSocket.write_timeout。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。