-->
Page 1 of 1

Problem with conn:connect

PostPosted: Wed Jul 22, 2015 3:50 pm
by JFRangelSerrano
Hi!! I have a problem!! If I type: "conn:connect(80,'google.com')" it works fine. But If I type: "conn:connect(85,'192.168.1.133')" to try connect with a .NET application listening in 192:168.1.133:85 socket it not works. I try to change port number and/or IP format ("192.168.1.133",'192.168.1.133') but no works too. Can you help me, please?

My source code (No works fine):

wifi.setmode(wifi.STATION)
wifi.sta.config("JAZZTEL_ymux","aaabbbcccddd")
conn=net.createConnection(net.TCP, 0)
conn:on("connection",function(conn, payload)
conn:send("Hello world")
end)
conn:connect(85,'192.168.1.133')



Good Code (Works fine):


wifi.setmode(wifi.STATION)
wifi.sta.config("JAZZTEL_ymux","aaabbbcccddd")
conn=net.createConnection(net.TCP, 0)

conn:on("connection",function(conn, payload)
conn:send("HEAD / HTTP/1.1\r\n"..
"Host: google.com\r\n"..
"Accept: */*\r\n"..
"User-Agent: Mozilla/4.0 (compatible; esp8266 Lua;)"..
"\r\n\r\n")
end)

conn:on("receive", function(conn, payload)
print('\nRetrieved in '..((tmr.now()-t)/1000)..' milliseconds.')
print('Google says it is '..string.sub(payload,string.find(payload,"Date: ")
+6,string.find(payload,"Date: ")+35))
conn:close()
end)
t = tmr.now()
conn:connect(80,'google.com')


I don't understand why my code no works fine. Help please! Thanks.