Forum: Ruby Processing the errorArray-subset returned by

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Sebastien Raveau (Guest)
on 2009-03-04 23:41
(Received via mailing list)
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 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 :-)
This topic is locked and can not be replied to.