forked from M-Labs/nac3
1
0
Fork 0

comms: replace TcpStream::listen() with TcpStream::accept()

This commit is contained in:
Astro 2020-04-16 22:11:11 +02:00 committed by Sebastien Bourdeauducq
parent b6c0f0baed
commit 5af2acc760
1 changed files with 11 additions and 5 deletions

View File

@ -18,7 +18,7 @@ use libboard_zynq::{
}; };
use libsupport_zynq::alloc::{vec, vec::Vec}; use libsupport_zynq::alloc::{vec, vec::Vec};
use libcortex_a9::sync_channel; use libcortex_a9::sync_channel;
use libasync::smoltcp::{Sockets, TcpStream}; use libasync::{smoltcp::{Sockets, TcpStream}, task};
use crate::kernel; use crate::kernel;
@ -209,11 +209,17 @@ pub fn main(mut sc_tx: sync_channel::Sender<usize>, mut sc_rx: sync_channel::Rec
Sockets::init(32); Sockets::init(32);
TcpStream::listen(1381, 2048, 2048, 8, |stream| async { task::spawn(async {
loop {
while let stream = TcpStream::accept(1381, 2048, 2048).await.unwrap() {
task::spawn(async {
let _ = handle_connection(stream) let _ = handle_connection(stream)
.await .await
.map_err(|e| println!("Connection: {}", e)); .map_err(|e| println!("Connection: {}", e));
}); });
}
}
});
let mut time = 0u32; let mut time = 0u32;
Sockets::run(&mut iface, || { Sockets::run(&mut iface, || {