-->
Page 2 of 3

Re: Block callback async

PostPosted: Sun Nov 30, 2014 1:39 pm
by alonewolfx2
i am trying your code but i have a problem with eof :S how i can figure this?

Code: Select alldofile("dnstest.lua")
lua: dnstest.lua:14: '<eof>' expected near 'end'

Re: Block callback async

PostPosted: Sun Nov 30, 2014 1:49 pm
by alonewolfx2
its working for me. i am getting right result.

Code: Select allmyhost="api.whatismyip.com"
> mypage=""
> myip=""
> sk=net.createConnection(net.TCP, 0)
> sk:dns(myhost,function(conn,ip)
>> myip=ip
>> sk=net.createConnection(net.TCP, 0)
>> sk:on("receive", function(sck, c) print(c) end )
>> sk:connect(80,myip)
>> sk:send("GET / " .. mypage .." HTTP/1.1\r\nHost: " .. myhost .."\r\n\r\n")
>> end)
> HTTP/1.1 403 Forbidden
Server: nginx
Date: Sun, 30 Nov 2014 18:40:05 GMT
Content-Type: text/html; charset=iso-8859-1
Content-Length: 10
Connection: keep-alive
Vary: Accept-Encoding

Forbidden.

Re: Block callback async

PostPosted: Sun Nov 30, 2014 1:49 pm
by ThomasW
The last 'end' in pete's code is one end too much at the end ;)

Re: Block callback async

PostPosted: Sun Nov 30, 2014 3:51 pm
by scargill
Hmm, that's creepy - there is one too many "end" in there - there HAS to be another end as I have one routine inside another. But it appeared to work once then reset so it's still not right...