]> git.lizzy.rs Git - rust.git/commit
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)
commit3c4e943881fc93136c4b6ad80f23aead9fee9d1b
tree94fad443f0a29b4429d942b345a6259af04c7bd8
parentb4ff0bca4c123399f8be8d44877e271767c5871c
parent58b2ff9f564833f5f4fa077a5708c139738dad8e
auto merge of #8954 : anasazi/rust/tcp-acceptor, r=catamorphism

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