I’m trying to use TCP connections, but none of my local-hosts will establish a connection. A message error is sent to me (Connection refused (os error 111)).
Here’s the code:
use std::io::prelude::*;
use std::net::{TcpStream, TcpListener};
fn main() {
let mut stream = match TcpStream::connect("127.0.0.1:80") {
Ok(stream) => stream,
Err(e) => panic!("{}", e),
};
let _ = stream.write(b"teste");
let mut buffer: [u8; 32] = [0; 32];
let _ = stream.read(&mut buffer);
println!("{:?}", &buffer);
}
What is possibly happening here? My system is Linux arch 4.2.5-1-ARCH.