Skip to content

Commit

Permalink
ci
Browse files Browse the repository at this point in the history
  • Loading branch information
irvingoujAtDevolution committed Feb 7, 2024
1 parent b11a2bf commit 80578fd
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions examples/tcp_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ fn main() -> io::Result<()> {

#[cfg(target_os = "windows")]
fn main() -> io::Result<()> {
use polling::Event;
use std::{io::Write, time::Duration};

std::thread::spawn(|| {
let listener = net::TcpListener::bind("0.0.0.0:8080").unwrap();
let listener = std::net::TcpListener::bind("0.0.0.0:8080").unwrap();
println!("Listening on {}", listener.local_addr().unwrap());
for stream in listener.incoming() {
let mut stream = match stream {
Expand All @@ -102,15 +103,15 @@ fn main() -> io::Result<()> {
}
});
std::thread::sleep(Duration::from_millis(100));
let socket = socket2::Socket::new(socket2::Domain::IPV4, Type::STREAM, None)?;
let socket = socket2::Socket::new(socket2::Domain::IPV4, socket2::Type::STREAM, None)?;
let poller = polling::Poller::new()?;
unsafe {
poller.add(&socket, Event::new(0, true, true))?;
}

socket.set_nonblocking(true)?;

let addr = net::SocketAddr::new("127.0.0.1".parse().unwrap(), 8080);
let addr = std::net::SocketAddr::new("127.0.0.1".parse().unwrap(), 8080);
let err = socket.connect(&addr.into()).unwrap_err();

assert_eq!(err.kind(), io::ErrorKind::WouldBlock);
Expand All @@ -129,8 +130,8 @@ fn main() -> io::Result<()> {
// // ========================================================================
// // the below is example of a bad socket
println!("testing bad socket");
let bad_socket = socket2::Socket::new(socket2::Domain::IPV4, Type::STREAM, None)?;
let addr = net::SocketAddr::new("127.0.0.1".parse().unwrap(), 12345);
let bad_socket = socket2::Socket::new(socket2::Domain::IPV4, socket2::Type::STREAM, None)?;
let addr = std::net::SocketAddr::new("127.0.0.1".parse().unwrap(), 12345);
bad_socket.set_nonblocking(true)?;
bad_socket.connect(&addr.into()).unwrap_err();

Expand Down

0 comments on commit 80578fd

Please sign in to comment.