Closed
Description
E.g. TcpListener has
use std::io::net::tcp::TcpListener;
use std::io::net::ip::{Ipv4Addr, SocketAddr};
use std::io::{Acceptor, Listener};
let addr = SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 80 };
let listener = TcpListener::bind(addr);
// bind the listener to the specified address
let mut acceptor = listener.listen();
// accept connections and process them
for stream in acceptor.incoming() {
spawn(proc() {
handle_client(stream);
});
}
// close the socket server
drop(acceptor);
but the handle_client
function isn't defined, and it's not particularly obvious what it should be, having something like
fn handle_client(mut stream: TcpStream) {
// ...
}
in the code too would make it easier to interpret. (I'm sure this isn't the only example of this.)
Metadata
Metadata
Assignees
Labels
No labels