Skip to content

Commit 530aca0

Browse files
author
brentru
committed
update example for dns client
1 parent 406ceb1 commit 530aca0

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

examples/wiznet5k_simpletest.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,21 @@
66
from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K
77
import adafruit_wiznet5k.adafruit_wiznet5k_socket as socket
88

9-
# Name address for wifitest.adafruit.com
10-
SERVER_ADDRESS = (('104.236.193.178'), 80)
11-
129
cs = digitalio.DigitalInOut(board.D10)
1310
spi_bus = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
1411

1512
# Initialize ethernet interface with DHCP
16-
eth = WIZNET5K(spi_bus, cs)
13+
eth = WIZNET5K(spi_bus, cs, debug=True)
1714

1815
print("DHCP Assigned IP: ", eth.pretty_ip(eth.ip_address))
1916

2017
socket.set_interface(eth)
2118

22-
# Create a new socket
23-
sock = socket.socket()
19+
host = 'wifitest.adafruit.com'
20+
port = 80
2421

25-
print("Connecting to: ", SERVER_ADDRESS[0])
26-
sock.connect(SERVER_ADDRESS)
22+
addr_info = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM)
23+
sock = socket.socket(addr_info[0], addr_info[1], addr_info[2])
2724

2825
print("Connected to ", sock.getpeername())
2926

0 commit comments

Comments
 (0)