0
我想將NodeMCU套接字客戶端連接到node.js套接字服務器。 我在NodeMCU中使用Lua編程語言。我爲客戶端嘗試了這個代碼,但它不起作用。使用Lua的NodeMCU套接字客戶端不連接
wifi.setmode(wifi.STATION)
wifi.sta.config("SSID","Password")
wifi.sta.connect()
ip = wifi.sta.getip()
print("your IP is "..ip)
sk = net.createConnection(net.TCP, 0)
sk:on("receive", function (sck,c)
print (c)
end)
sk:on("connection", function (sck,c)
print("connected")
sk:send("Helloooo...")
end)
sk:connect(3000,"192.168.1.4")
node.js服務器代碼已測試並運行良好。
var app = require('http').createServer();
var io = require('socket.io')(app);
io.on('connection', function(socket){
console.log('someone is connected');
});
app.listen(3000);