Generation

generate functionSat, 12 Nov 2022

Read a message from a socket where the first byte represents the length of the message

use std::io::{TcpListener, TcpStream}; fn main() { let listener = TcpListener::bind("127.0.0.1:8000"); let mut stream = listener.unwrap().accept().unwrap().0; let len = stream.read_byte().unwrap(); stream.read_exact(len); }

Questions about programming?Chat with your personal AI assistant