Yohanes Santoso
3/26/2005 8:39:00 PM
Ed Wildgoose <ed@wildgooses.com> writes:
>> So, whether you are setting the fd to NB mode yourself or not, your
>> connect won't block (assuming your OS supports NB operation).
The word "your" above is misleading (and wrong?). It should be "the
connect operation you initiated from the ruby land, will not block the
ruby vm.
> On win32 if I open a TCP socket will it will return immediately?
No
> Presumably then I won't find out the success of failure of the
> socket open until some later time when the async open completes?
WRT your ruby code, the Socket#connect call won't return until either
it is successful or failed.
What I meant above is: the ruby vm will not be blocked just because
you do a Socket#connect in blocking mode. The ruby vm will be able to
schedule other threads to run while it waits for the success/failure
of the connect syscall.
This means (from ruby land), if it takes x seconds to call the connect
syscall and wait for its result, then doing 100 Socket#connect on 100
threads will take less than 1000*x seconds.
YS.