created basic tcp listener

This commit is contained in:
Nickiel12 2021-12-17 12:39:11 -08:00
parent 5264001ab5
commit 264b496ef2
2 changed files with 19 additions and 1 deletions

View file

@ -2,6 +2,16 @@
mod tests;
mod modules;
use std::net::{TcpListener, TcpStream, Shutdown};
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()
}

View file

@ -1,6 +1,14 @@
use crate::make_listener;
#[test]
fn it_works() {
let result = 2 + 2;
assert_eq!(result, 4);
}
#[test]
fn can_make_socket_listener(){
let listener = make_listener(String::from("localhost:5000"));
drop(listener);
}