From 50e1d257bd192a864a11b6e1edc86298eda7b943 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Sat, 23 Apr 2022 05:14:44 +0200 Subject: [PATCH] net: change listen() to accept(), which waits until the connection is established. --- embassy-net/src/tcp_socket.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/embassy-net/src/tcp_socket.rs b/embassy-net/src/tcp_socket.rs index 4836f807..5637505d 100644 --- a/embassy-net/src/tcp_socket.rs +++ b/embassy-net/src/tcp_socket.rs @@ -58,7 +58,7 @@ impl<'a> TcpSocket<'a> { .await } - pub async fn listen(&mut self, local_endpoint: T) -> Result<()> + pub async fn accept(&mut self, local_endpoint: T) -> Result<()> where T: Into, { @@ -66,9 +66,7 @@ impl<'a> TcpSocket<'a> { futures::future::poll_fn(|cx| { self.with(|s, _| match s.state() { - TcpState::Closed | TcpState::TimeWait => Poll::Ready(Err(Error::Unaddressable)), - TcpState::Listen => Poll::Ready(Ok(())), - TcpState::SynSent | TcpState::SynReceived => { + TcpState::Listen | TcpState::SynSent | TcpState::SynReceived => { s.register_send_waker(cx.waker()); Poll::Pending }