-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split out starting a listener from accepting incoming connections.
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: 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 (or until you break out of the loop) }
- Loading branch information
Showing
6 changed files
with
181 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
58b2ff9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from catamorphism
at anasazi@58b2ff9
58b2ff9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging anasazi/rust/tcp-acceptor = 58b2ff9 into auto
58b2ff9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anasazi/rust/tcp-acceptor = 58b2ff9 merged ok, testing candidate = 3c4e943
58b2ff9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/1254
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/1257
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/363
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/363
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/1273
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/364
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/364
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/1273
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/364
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/364
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android/builds/445
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/1257
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/363
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/363
success: http://buildbot.rust-lang.org/builders/auto-bsd-64-opt/builds/1042
58b2ff9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = 3c4e943