22.01.2018, 22:36
(22.01.2018, 17:19)Mr. Danielsen Wrote: Hi,
Could some help with writing a TCP/IP protocol command?
I would like to send a command to ip address 1.1.1.1 with port 11.
The command is PWON and the regular expression is <CR>
This is so I can communicate with my Denon AVR.
Also for status I like know how to pull/request a status..?
Anyone?
BR
Mr.D
Try this:
Code:
nextline = '\r\n'
local socket = require("socket")
local tcp = assert(socket.tcp())
tcp:settimeout(0.3)
connected,err = tcp:connect('1.1.1,1', '5000')
result,err = tcp:send('PWON' .. nextline)
local rec,status,partial = tcp:receive('*a')
closing = tcp:close()