-
Notifications
You must be signed in to change notification settings - Fork 26
Description
When running the sample:
s = TCPSocket.open("www.kame.net", 80)
s.write("GET / HTTP/1.0\r\n\r\n")
puts s.read
s.close
The AddrInfo.foreach on line 236 here https://github.com/iij/mruby-socket/blob/master/mrblib/socket.rb#L236 will always evalute the block for each address returned. On Slackware 14.2,
the getaddrinfo call is currently returning an array of 6 addresses for www.kame.net, and will
attempt to connect to each of those 6 addresses.
After creating multiple sockets (opening multiple fds and connecting to each addr, it then will raise SocketError (because the return on 247 only leaves the local block, not the top level block).
to fix this the top level each should break as soon as one address succeeds, and the error should not be raised after the block, unless the error was set by one of the socket operations caught by rescue.