Adafruit has this code for making a HTTP request:
sk=net.createConnection(net.TCP, 0) sk:on("receive", function(sck, c) print(c) end ) sk:connect(80,"www.adafruit.com") sk:send("GET /testwifi/index.html HTTP/1.1\r\nHost: www.adafruit.com\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n")
The bizarre thing is that this works fine entered line-by-line in the terminal, but if I toss it in a lua file and run it with dofile, it doesn't work. But if I change "www.adafruit.com" in sk:connect to the IP for www.adafruit.com, it works in the file. I wonder if there's a race with the DNS where it can't do the DNS lookup fast enough, and then sk:send tries to send before it's completely connected. I'm going to report it to the NodeMCU devs, but for now I'm going to be using the Arduino port to the ESP8266.