Fix issue 2280

Correct logic in Native.finishConnect.  Fix use of optval parameter in c getOption function.  

In epoll event loop, check that channel is open before processing event.  On connect failure the fd is ready for both write and read events.  Processing the write event closes the channel, which then causes the read to fail with an exception.