summaryrefslogtreecommitdiffstats
path: root/tokio/tests
diff options
context:
space:
mode:
authorZeki Sherif <9832640+zekisherif@users.noreply.github.com>2020-11-17 11:58:00 -0600
committerGitHub <noreply@github.com>2020-11-17 09:58:00 -0800
commit7d11aa866837eea50a6f1e0ef7e24846a653cbf1 (patch)
treeca0d5edc04a29bbe6e2906c760a22908e032a4c9 /tokio/tests
parent0ea23076503c5151d68a781a3d91823396c82949 (diff)
net: add SO_LINGER get/set to TcpStream (#3143)
Diffstat (limited to 'tokio/tests')
-rw-r--r--tokio/tests/tcp_stream.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/tokio/tests/tcp_stream.rs b/tokio/tests/tcp_stream.rs
index 84d58dc5..58b06ee3 100644
--- a/tokio/tests/tcp_stream.rs
+++ b/tokio/tests/tcp_stream.rs
@@ -9,10 +9,26 @@ use tokio_test::{assert_ok, assert_pending, assert_ready_ok};
use std::io;
use std::task::Poll;
+use std::time::Duration;
use futures::future::poll_fn;
#[tokio::test]
+async fn set_linger() {
+ let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
+
+ let stream = TcpStream::connect(listener.local_addr().unwrap())
+ .await
+ .unwrap();
+
+ assert_ok!(stream.set_linger(Some(Duration::from_secs(1))));
+ assert_eq!(stream.linger().unwrap().unwrap().as_secs(), 1);
+
+ assert_ok!(stream.set_linger(None));
+ assert!(stream.linger().unwrap().is_none());
+}
+
+#[tokio::test]
async fn try_read_write() {
const DATA: &[u8] = b"this is some data to write to the socket";