forked from M-Labs/zynq-rs
libasync: add TcpSocket::{close, abort, keep_alive, timeout}()
This commit is contained in:
parent
60e45f096d
commit
bcedd02ad9
@ -14,6 +14,7 @@ use smoltcp::{
|
||||
SocketHandle, SocketRef,
|
||||
TcpSocketBuffer, TcpSocket, TcpState,
|
||||
},
|
||||
time::Duration,
|
||||
};
|
||||
use crate::task;
|
||||
use super::Sockets;
|
||||
@ -217,6 +218,38 @@ impl TcpStream {
|
||||
}
|
||||
}).await
|
||||
}
|
||||
|
||||
/// Close the transmit half of the connection
|
||||
pub async fn close(&self) {
|
||||
self.with_socket(|mut socket| socket.close());
|
||||
|
||||
// Yield for one iface.poll() to send the packet
|
||||
task::r#yield().await;
|
||||
}
|
||||
|
||||
/// Destroy the socket, sending the RST
|
||||
pub async fn abort(self) {
|
||||
self.with_socket(|mut socket| socket.abort());
|
||||
|
||||
// Yield for one iface.poll() to send the packet
|
||||
task::r#yield().await;
|
||||
}
|
||||
|
||||
pub fn keep_alive(&self) -> Option<Duration> {
|
||||
self.with_socket(|socket| socket.keep_alive())
|
||||
}
|
||||
|
||||
pub fn set_keep_alive(&mut self, interval: Option<Duration>) {
|
||||
self.with_socket(|mut socket| socket.set_keep_alive(interval));
|
||||
}
|
||||
|
||||
pub fn timeout(&self) -> Option<Duration> {
|
||||
self.with_socket(|socket| socket.timeout())
|
||||
}
|
||||
|
||||
pub fn set_timeout(&mut self, duration: Option<Duration>) {
|
||||
self.with_socket(|mut socket| socket.set_timeout(duration));
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TcpStream {
|
||||
|
Loading…
Reference in New Issue
Block a user