Page 2 of 2

Re: uPing - Ping library for MicroPython

Posted: Thu May 09, 2019 7:37 am
by nedoskiv
and here is the fix I have maded:

Code: Select all

 # init socket
    sock = usocket.socket(usocket.AF_INET, usocket.SOCK_RAW, 1)
    sock.setblocking(0)
    sock.settimeout(timeout/1000)
    try:
	    addr = usocket.getaddrinfo(host, 1)[0][-1][0] # ip address
    except:
        print("Unable to resolve: "+host)
        sock.close()
        return(0,0)
    sock.connect((addr, 1))
    not quiet and print("PING %s (%s): %u data bytes" % (host, addr, len(pkt)))