:start loop do case state when :start # ... state = :v6c when :v4w # ... when :v6c, :v4c, :v46c # ... when :v46w # ... when :success # ... end end ,FSOFMMPPQͱDBTFจͷΈ߹ΘͤʹΑΓঢ়ଶભҠΛදݱ͢Δ ϧʔϓͰঢ়ଶʹԠͯ͡ॲཧΛߦ͍ɺ৽͍͠ঢ়ଶΛઃఆ͠ɺ ࣍ͷϧʔϓʹೖΔ ϧʔϓʹ͖ͭঢ়ଶભҠΛදݱ ঢ়ଶΛTUBSUʹॳظԽ
case state # ... when :success break connected_socket when :failure raise last_error when :timeout raise Errno::ETIMEDOUT, "user specified timeout" end end if block_given? begin yield ret ensure ret.close end else ret end end ঢ়ଶભҠͷऴྃঢ়ଶΛܦ༝ͯ͠ɺ ϧʔϓ͔Βൈ͚Δ͔ྫ֎Λൃੜͤ͞Δ ϧʔϓ͔Βൈ͚ͨ߹ଓࡁΈιέοτΛฦͯ͠ऴྃ ऴྃঢ়ଶ ଓࡁΈͷιέοτΛฦ͢ ࣮ͷେ 4PDLFUUDQ ऴྃॲཧ
# ໊લղܾͷ։࢝ # IO.select(<໊લղܾ>, <ଓ>, nil, <λΠϜΞτ>) # if ॻ͖ࠐΈՄೳͳIO͕ฦ͖ͬͯͨ then ଓ֬ೝɹ(ޭ͍ͯͨ͠Βreturn) # if ಡΈࠐΈՄೳͳIO͕ฦ͖ͬͯͨ then ղܾࡁΈͷIPΞυϨεΛอଘ # if ଓ։࢝ͷ݅Λຬ͍ͨͯ͠Δ then ଓΛ։࢝ # unless ࣍ͷϧʔϓʹೖΔ͜ͱ͕Ͱ͖Δ then ྫ֎Λൃੜͤ͞Δ ঢ়ଶͷཧΛΊͨ͜ͱͰɺ վળલDBTF͝ͱʹ࣮ߦ͍ͯͨ͠ॲཧ͕ ϧʔϓͷ্͔Βॱʹ݅ʹԠ࣮ͯ͡ߦ͞ΕΔΑ͏ʹͳͬͨ
ɹɹͲͷঢ়ଶʹͳΔͷ͔ʯʹґଘ͢Δ ▫มߋޙ ɾଓΛ։࢝Ͱ͖Δ͔Ͳ͏͔Λ ɹͦͷ࣌ͰͷϦιʔεͷঢ়گɺ ɹશମͷॲཧ͕Ͳ͜·ͰਐΜͰ͍Δ͔ɺ ɹͳͲʹΑͬͯஅ͢Δ if resolved_addrinfos.any? && !resolv_delay_expires_at && !connect_delay_expires_at while (addrinfo = resolved_addrinfos.get) # ... end end
ɹΓͨ͠ॲཧ ɹ·ͩଓ͍͍ͯΔॲཧ͕ͳ͍͔Λஅ͠ɺ ɹ͜ΕҎ্Ͱ͖Δॲཧ͕ͳ͚Ε ɹྫ֎Λൃੜͤ͞Δ if resolved_addrinfos.empty? if connecting_sockets.keys.empty? && resolved_addrinfos.resolved_all? raise last_error end # ... end