Skip to content

Commit 4d8bdd2

Browse files
authored
Merge pull request #147 from prisma/try-out-all-resolved-ips
Detect connection errors when resolving
2 parents 6798f38 + 159fdd3 commit 4d8bdd2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/io/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,21 @@ impl Stream {
359359
let mut stream = socket.connect(addr)?;
360360
let mut poll = mio::Poll::new()?;
361361
let mut events = mio::Events::with_capacity(1024);
362+
362363
poll.registry()
363364
.register(&mut stream, mio::Token(0), mio::Interest::WRITABLE)?;
365+
364366
loop {
365367
poll.poll(&mut events, None)?;
366368

367369
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+
368377
if event.token() == mio::Token(0) && event.is_writable() {
369378
// The socket connected (probably, it could still be a spurious
370379
// wakeup)

0 commit comments

Comments
 (0)