def tries
import bend-kit-dns@0.7.0.0/dns.bend as Dnsimport Base
494# fuel: attempts left (resolv.conf's default is 2).
495def tries(fuel: Nat, +ns: String, +id: U32, +name: String, st: Socket & Try) -> IO(Maybe<&2, String>):
496 match fuel:
497 case 0n:
498 tries.end(st)
499 case 1n+f:
500 (s, t) = st
501 match t:
502 case Got{ip}:
503 try.close(s, ip)
504 case Again{}:
505 do IO<Maybe<&2, String>>:
506 next : Socket & Try <- try.once(s, ns, id, name)
507 tries(f, ns, id, name, next)