akka/akka — pull request #1773 by bantonsson (2013-10-16 10:53:09+00:00)
Title: (backport) =act #3602 report `Connected` only when connection attempt was successful

Before this change, a client connection was always instantly reported as
`Connected`, even if the endpoint would never respond at all.

The reason is a weird behavior of OP_CONNECT and SocketChannel in the JDK
(observed in Linux):
- a channel is always connectable before the connection is attempted
(`channel.connect`). Selecting for OP_CONNECT before the `connect`
call will instantly report connectable
- even worse: after OP_CONNECT was reported true, also `finishConnect`
will always return true, even if the connection wasn't yet established.
That's probably the case because `finishConnect` is internally implemented
depending on previous epoll results (on Linux).