// esp8266 test net connection
var ssid = "<SSID>";
var pass = "<PASSWORD>";
var serverip = "192.168.xxx.xxx";
// network connection
var wifi = require("wifi");
var net = require("net");
var ipInfo = ESP8266WiFi.getIPInfo();
print("IP addr: " + ESP8266WiFi.getAddressAsString(ipInfo.ip));
// update sample and send new data
function sample() {
var skt = net.connect({host: serverip, port: 1234}, function() {
skt.write(getTime().toString()+"\n");
skt.end();
console.log(process.memory());
});
}
//setInterval('sample();', 5000);
The process.memory() function returns the same values hundreds of times, then begins to increment used memory:
---results from console.log()---
--several hundred lines like the two immediately below:
{ "free": 821, "usage": 202, "total": 1023, "history": 141 }
{ "free": 821, "usage": 202, "total": 1023, "history": 141 }
Uncaught Error: Function "write" not found!
at line 3 col 14
skt.write(getTime().toString()+"\n");
^
in function called from system
WARNING: Prototype is not an Object, so setting it to {}
{ "free": 803, "usage": 220, "total": 1023, "history": 141 }
{ "free": 753, "usage": 270, "total": 1023, "history": 141 }
{ "free": 703, "usage": 320, "total": 1023, "history": 141 }
{ "free": 653, "usage": 370, "total": 1023, "history": 141 }
{ "free": 603, "usage": 420, "total": 1023, "history": 141 }
{ "free": 553, "usage": 470, "total": 1023, "history": 141 }
{ "free": 503, "usage": 520, "total": 1023, "history": 141 }
{ "free": 453, "usage": 570, "total": 1023, "history": 141 }
{ "free": 403, "usage": 620, "total": 1023, "history": 141 }
ERROR: Unable to create socket
I am learning javascript and this is very possibly due to a programming or conceptual error. I cannot find any information about a useful return code from the net.connect() function, but it seems that at some point it cannot create a socket. Any thoughts of what is happening would surely be instructive.
Thanks, Duane