As the title says... Chat on...

User avatar
By StefanL38
#70016 Hello,

I'm struggling with writing a Lua-script that sends back and forth data between a TCP-server and TCP-client.
In my learning-process I want to know what events can happen in relation to a TCP-client.
As far as I know it until now there are

on("receive",

on("sent",

I got the impression that there are mor events than just "receive" and "sent"

I have searched up and down the https://nodemcu.readthedocs.io
but I haven't found any more yet.

Does this mean that the documentation is not completed?
maybe the docs are organised in a way I do not yet understand. Is it possible that there is a different section
that lists up all the possible events but in a completely different chapter?
if so could somebody guide me there?

best regards

Stefan
User avatar
By devsaurus
#70017 In the API doc for net.socket:on?
https://nodemcu.readthedocs.io/en/maste ... etsocketon

While a server just has a callback for listen
https://nodemcu.readthedocs.io/en/maste ... rverlisten

And for a DNS query you get called back when the result is available (also available for a socket)
https://nodemcu.readthedocs.io/en/maste ... dnsresolve
User avatar
By StefanL38
#70020 Hi devsaurus,

thank you so much for guiding me. As I'm an almost totally noob to Lua I had "tomatoes" on my eyes.
Thank you so much for "taking them away" ;-))

I wasn't able to understand how net.createConnection() is related to the net.socket-submodule.
I made the wrong conclusion that each character-sequence behind "net" is a different and unrelated command.

As there was nothing written about events under net.createConnection() I made the wrong conclusion
it is not documented. I have searched for "event" and of course found "net.socket:on()" but again I made the wrong conclusion that "net.socket:on()" is a different command which is NOT related to "net.createConnection() "

experts never would have this problem because they are experts.
I call this effect "expert-blindness-to-beginners-difficulties"

The docs are written VERY short assuming that readers know a lot about Lua in general already.

Do you happen to know if somebody already started a "Beginners Guide to nodeMCU-Lua" ?
if yes let me know. I would like to contribute to that while I'm learning myself as a beginner I'm an "expert" for beginners difficulties. If there is nothing liek that yet I will start it on my own.

Now as I have the overview about the events I can do experiments with it to learn about its behaviour.

If you happen to have Lua-code that shows how data can be exchanged between two ESP8266-modules over WiFi in the appropriate eventdriven stile (=not quick & dirty) but with maximum possible reliability this would make me ultra-hyper-happy.

best regards

Stefan
User avatar
By marcelstoer
#70024
StefanL38 wrote:The docs are written VERY short assuming that readers know a lot about Lua in general already.


That's highly subjective of course but I'd argue that our documentation is far from short. Keep in mind that this is a NodeMCU API documentation. It's neither a tutorial nor is it a Lua primer - it shouldn't be. Likewise I wouldn't turn to Oracle's Java API documentation if I wanted to learn Java.