mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-17 05:05:03 +01:00
version negotiation
This commit is contained in:
parent
b2e6e96698
commit
b77788329c
5 changed files with 107 additions and 8 deletions
|
|
@ -1,10 +1,22 @@
|
|||
use anyhow::{Context, Result};
|
||||
use tokio::io::AsyncWriteExt;
|
||||
mod connection;
|
||||
|
||||
use crate::connection::Connection;
|
||||
use anyhow::Result;
|
||||
use tokio::net;
|
||||
use tracing::info;
|
||||
|
||||
pub async fn do_thing_i_guess() -> Result<()> {
|
||||
tokio::io::stdout()
|
||||
.write(b"hello async world lol\n")
|
||||
.await
|
||||
.context("failed to write")
|
||||
.map(drop)
|
||||
info!("Binding TCP listener...");
|
||||
let listener = net::TcpListener::bind(("127.0.0.1", 5672)).await?;
|
||||
info!(addr = ?listener.local_addr()?, "Successfully bound TCP listener");
|
||||
|
||||
loop {
|
||||
let (stream, _) = listener.accept().await?;
|
||||
|
||||
info!(local_addr = ?stream.local_addr(), "Accepted new connection");
|
||||
|
||||
let connection = Connection::new(stream);
|
||||
|
||||
tokio::spawn(connection.start());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue