use compio::net::{TcpListener, TcpStream};
use monocoque::zmq::{DealerSocket, RouterSocket};
use std::time::Duration;
use tracing::info;
#[compio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::INFO)
.init();
info!("=== ZMTP Handshake Test ===\n");
let server_task = compio::runtime::spawn(async {
info!("[SERVER] Binding...");
let listener = TcpListener::bind("127.0.0.1:5571").await.unwrap();
info!("[SERVER] Listening on :5571");
let (stream, _addr) = listener.accept().await.unwrap();
info!("[SERVER] Connection accepted");
let _socket = RouterSocket::from_tcp(stream).await;
info!("[SERVER] Socket created");
info!("[SERVER] Handshake complete");
info!("[SERVER] Done");
});
compio::time::sleep(Duration::from_millis(100)).await;
info!("[CLIENT] Connecting...");
let stream = TcpStream::connect("127.0.0.1:5571").await?;
info!("[CLIENT] Connected");
let _socket = DealerSocket::from_tcp(stream).await;
info!("[CLIENT] Socket created");
info!("[CLIENT] Handshake complete");
info!("[CLIENT] Done");
server_task.await;
info!("\n✅ Handshake test completed successfully!");
Ok(())
}