created basic tcp listener
This commit is contained in:
parent
5264001ab5
commit
264b496ef2
2 changed files with 19 additions and 1 deletions
12
src/main.rs
12
src/main.rs
|
@ -2,6 +2,16 @@
|
||||||
mod tests;
|
mod tests;
|
||||||
mod modules;
|
mod modules;
|
||||||
|
|
||||||
|
use std::net::{TcpListener, TcpStream, Shutdown};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
let listener = make_listener(String::from("localhost:5000"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
drop(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn make_listener(address: String) -> TcpListener {
|
||||||
|
TcpListener::bind(address).unwrap()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
|
use crate::make_listener;
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn it_works() {
|
||||||
let result = 2 + 2;
|
let result = 2 + 2;
|
||||||
assert_eq!(result, 4);
|
assert_eq!(result, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn can_make_socket_listener(){
|
||||||
|
let listener = make_listener(String::from("localhost:5000"));
|
||||||
|
drop(listener);
|
||||||
|
}
|
Loading…
Reference in a new issue