uPing - Ping library for MicroPython

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
nedoskiv
Posts: 8
Joined: Fri Jan 18, 2019 10:48 am

Re: uPing - Ping library for MicroPython

Post by nedoskiv » Thu May 09, 2019 7:37 am

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)))

Post Reply