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

User avatar
By Ripper121
#23809 How can i connect to a tcp (telnet) server and when a pin changes send a Alarm message to the server.

In my code it dont work (if i remove the last to lines the server get 1 alarm but more is not possible)

Code: Select allsk=net.createConnection(net.TCP, 0)
    sk:on("receive", function(sck, c) print(c) end )
    sk:connect(8080,"192.168.43.1")
    sk:send("alarm!\r\n")
    sk:send("alarm!\r\n")
    sk:close()
User avatar
By TerryE
#24155 Read the FAQ in the link below. The sends are synchronous. Don't do multiple sends from the same event callback. Only close the connection after the last send has been sent or if the other end closes the connection -- use the sk:on() function and callbacks with the "sent" or "disconnection" selector.