14 lines
281 B
Rust
14 lines
281 B
Rust
use std::net::TcpStream;
|
|
use std::io::Error;
|
|
|
|
pub struct Client {
|
|
stream: TcpStream
|
|
}
|
|
|
|
impl Client {
|
|
pub fn new(host: &str, port: &str) -> Result<Self, Error> {
|
|
let mut stream = TcpStream::connect(format!("{}:{}", host, port))?;
|
|
|
|
Ok(Self { stream })
|
|
}
|
|
} |