iij/mruby-socket

connect_nonblock

mowrang opened this issue · 2 comments

I would like to use a nonblocking connect as described in the below artcile.

http://spin.atomicobject.com/2013/09/30/socket-connection-timeout-ruby/

It seems mruby-socket gem hasn't implemented connect_nonblock.

Is there any equivalent of connect_nonblock that I can use in mruby? Or do I have to implement my own connect_nonblock?

thanks,

Maryam

We have Socket#connect_nonblock. Doesn't it what you want?

s = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
s.connect_nonblock(Socket.sockaddr_in(80, "127.0.0.1"))
s.write "GET / HTTP/1.0\r\n\r\n"
p s.gets
% mruby a.rb
"HTTP/1.1 200 OK\r\n"
%

yes, thanks!