# Processing the errorArray-subset returned by IO.select()

**URL:** <https://www.ruby-forum.com/t/processing-the-errorarray-subset-returned-by-io-select/162014>\
**Category:** Ruby\
**Created:** [March 4, 2009, 10:41pm UTC](https://www.ruby-forum.com/t/processing-the-errorarray-subset-returned-by-io-select/162014 "2009-03-04T22:41:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sebastien\_Raveau](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9de053/32.png) [@Sebastien\_Raveau](https://www.ruby-forum.com/u/Sebastien_Raveau)\
**Post date:** [March 4, 2009, 10:41pm UTC](https://www.ruby-forum.com/t/processing-the-errorarray-subset-returned-by-io-select/162014/1 "2009-03-04T22:41:51Z")

</div>

Hi everybody!

I am posting my question to this list really as a last recourse after  
having duly searched Ruby’s doc, Google, Ruby’s source, IRC, etc…  
Can somebody please end my torment?

What I’m trying to achieve is a fully asynchronous HTTP proxy (or, for  
the sake of simplicity let’s just say a TCP relay between A and B) in  
just one thread, meaning:

- when I non-blockingly (select+accept) get a new connection from A, I  
have to open the relay connection to B using connect\_nonblock
- upon “readable” events on sockets belonging to either A or B, I must  
non-blockingly write() to the other (or cache the data and wait for  
the other socket to be “writable”)
- have to teardown the relay as soon as any side shows signs of  
connect timeout, close, reset, etc

Now, in order to monitor socket status I cannot rely on  
begin/rescue/end (actually I found a tutorial where the author calls  
connect\_nonblock a second time and checks EISCONN to see if the socket  
connection was successful, but that’s not the best way to do it, is  
it?), so I thought my answer was in the third array returned by  
select, concerning socket errors/exceptions… but I cannot find any  
documentation on that, and everybody seems to call IO.select() with  
‘nil’ as third argument :-/

Does anybody know how to process it? Is there a way to get the  
corresponding Errno for each socket?

Thank you 🙂
