-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More beginner-friendly TCP server example #102
Conversation
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.
Thanks a ton Lee. Please reach out if any comments are unclear.
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.
Thanks again, and sorry for the delayed response.
src/08_example/05_tests.md
Outdated
One strategy could be to refactor the code to be more modular, | ||
and only test that the correct responses are returned for the respective inputs. | ||
|
||
Another strategy is to connect to `localhost` on port 0. |
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.
What's wrong with the port you used, 7878?
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.
7878 is fine, but I wrote this due to a preference that the test code should be able to run on any server, where other things might be using port 7878. I believe I also saw this used in the tests for smol
. No strong preference here.
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.
Thanks so much Lee. Great to see this. Just a couple of minor nits left, but LGTM. There are also a couple of spellchecker quirks remaining.
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.
Looks good! I left a few more nits and suggestions, otherwise I think this is ready to merge.
Merged. Thank you! |
I wanted to write an example to help guide people new to asynchronous programming, with fewer external dependencies (as some people requested in #66). The example starts with the [single threaded TCP server from the Rust book](https://doc.rust-lang.org/book/ch20-01-single-threaded.html) and uses async functionality to add concurrency. The example goes through: - some examples of blocking code and how to make them non blocking (should address #64 as well) - spawning tasks vs using combinators to run them concurrently on a single thread - testing code by creating mocks and implementing async read/write traits for the mocks
I wanted to write an example to help guide people new to asynchronous programming, with fewer external dependencies (as some people requested in #66). The example starts with the [single threaded TCP server from the Rust book](https://doc.rust-lang.org/book/ch20-01-single-threaded.html) and uses async functionality to add concurrency. The example goes through: - some examples of blocking code and how to make them non blocking (should address #64 as well) - spawning tasks vs using combinators to run them concurrently on a single thread - testing code by creating mocks and implementing async read/write traits for the mocks
I wanted to write an example to help guide people new to asynchronous programming, with fewer external dependencies (as some people requested in #66). The example starts with the [single threaded TCP server from the Rust book](https://doc.rust-lang.org/book/ch20-01-single-threaded.html) and uses async functionality to add concurrency. The example goes through: - some examples of blocking code and how to make them non blocking (should address #64 as well) - spawning tasks vs using combinators to run them concurrently on a single thread - testing code by creating mocks and implementing async read/write traits for the mocks
I wanted to write an example to help guide people new to asynchronous programming, with fewer external dependencies (as some people requested in #66). The example starts with the single threaded TCP server from the Rust book and uses async functionality to add concurrency.
The example goes through:
thread::sleep
inside an async fn #64 as well)Happy to receive any feedback.