We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6798f38 + 159fdd3 commit 4d8bdd2Copy full SHA for 4d8bdd2
src/io/mod.rs
@@ -359,12 +359,21 @@ impl Stream {
359
let mut stream = socket.connect(addr)?;
360
let mut poll = mio::Poll::new()?;
361
let mut events = mio::Events::with_capacity(1024);
362
+
363
poll.registry()
364
.register(&mut stream, mio::Token(0), mio::Interest::WRITABLE)?;
365
366
loop {
367
poll.poll(&mut events, None)?;
368
369
for event in &events {
370
+ if event.token() == mio::Token(0) && event.is_error() {
371
+ return Err(io::Error::new(
372
+ io::ErrorKind::ConnectionRefused,
373
+ "Connection refused",
374
+ ));
375
+ }
376
377
if event.token() == mio::Token(0) && event.is_writable() {
378
// The socket connected (probably, it could still be a spurious
379
// wakeup)
0 commit comments