From 5af2acc7606a3a24405ab58a7730bd24e04c4dce Mon Sep 17 00:00:00 2001 From: Astro Date: Thu, 16 Apr 2020 22:11:11 +0200 Subject: [PATCH] comms: replace TcpStream::listen() with TcpStream::accept() --- runtime/src/comms.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/runtime/src/comms.rs b/runtime/src/comms.rs index 6a0ffb5..3c71e14 100644 --- a/runtime/src/comms.rs +++ b/runtime/src/comms.rs @@ -18,7 +18,7 @@ use libboard_zynq::{ }; use libsupport_zynq::alloc::{vec, vec::Vec}; use libcortex_a9::sync_channel; -use libasync::smoltcp::{Sockets, TcpStream}; +use libasync::{smoltcp::{Sockets, TcpStream}, task}; use crate::kernel; @@ -209,10 +209,16 @@ pub fn main(mut sc_tx: sync_channel::Sender, mut sc_rx: sync_channel::Rec Sockets::init(32); - TcpStream::listen(1381, 2048, 2048, 8, |stream| async { - let _ = handle_connection(stream) - .await - .map_err(|e| println!("Connection: {}", e)); + task::spawn(async { + loop { + while let stream = TcpStream::accept(1381, 2048, 2048).await.unwrap() { + task::spawn(async { + let _ = handle_connection(stream) + .await + .map_err(|e| println!("Connection: {}", e)); + }); + } + } }); let mut time = 0u32;