]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #8954 : anasazi/rust/tcp-acceptor, r=catamorphism
authorbors <bors@rust-lang.org>
Tue, 3 Sep 2013 21:56:22 +0000 (14:56 -0700)
committerbors <bors@rust-lang.org>
Tue, 3 Sep 2013 21:56:22 +0000 (14:56 -0700)
The Listener trait takes two type parameters, the type of connection and the type of Acceptor,
and specifies only one method, listen, which consumes the listener and produces an Acceptor.

The Acceptor trait takes one type parameter, the type of connection, and defines two methods.
The accept() method waits for an incoming connection attempt and returns the result.
The incoming() method creates an iterator over incoming connections and is a default method.

Example:

```rust
let listener = TcpListener.bind(addr); // Bind to a socket
let acceptor = listener.listen(); // Start the listener
for stream in acceptor.incoming() {
    // Process incoming connections forever (a failure will kill the task).
}
```

Closes #8689


Trivial merge