<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Topics tagged with gettaddrinfo]]></title><description><![CDATA[A list of topics that have been tagged with gettaddrinfo]]></description><link>https://forum.pycom.io/tags/gettaddrinfo</link><generator>RSS for Node</generator><lastBuildDate>Mon, 16 Mar 2026 02:24:35 GMT</lastBuildDate><atom:link href="https://forum.pycom.io/tags/gettaddrinfo.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 03 Nov 2019 01:13:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[getaddrinfo in a thread]]></title><description><![CDATA[Just retyped this for the sake of improved readability. You might want to save it as /flash/lib/dnstest.py.
import time
import usocket
import machine
import _thread
&quot;&quot;&quot;
&gt;&gt;&gt; import dnstest; dnstest.dns_lookup('google.com')
0 None
1 (2, 1, 0, '', ('172.217.18.14', 443))
2 (2, 1, 0, '', ('172.217.18.14', 443))
3 (2, 1, 0, '', ('172.217.18.14', 443))
4 (2, 1, 0, '', ('172.217.18.14', 443))
&quot;&quot;&quot;

response = None


def run_getaddrinfo(host, port):
    global response
    response = usocket.getaddrinfo(host, port)[0]


def dns_lookup(hostname, timeout=5):

    _thread.start_new_thread(run_getaddrinfo, (hostname, 443))

    for i in range(timeout):
        print(i, response)
        machine.idle()
        time.sleep(1)

    print('Ready.')

It works flawlessly over a WiFi connection, but LTE might well have its delicacies.
]]></description><link>https://forum.pycom.io/topic/5295/getaddrinfo-in-a-thread</link><guid isPermaLink="true">https://forum.pycom.io/topic/5295/getaddrinfo-in-a-thread</guid><dc:creator><![CDATA[andreas]]></dc:creator><pubDate>Sun, 03 Nov 2019 01:13:47 GMT</pubDate></item></channel></rss>