How to use LUA to Control Sony Bravia TV over IP

I have tried this:

os.execute([[curl --silent -XPOST http://192.168.1.104/sony/IRCC -H "X-Auth-PSK:1111" -d "<?xml version=\"1.0\"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="[http://schemas.xmlsoap.org/soap/encoding/ ](http://schemas.xmlsoap.org/soap/encoding/)"><s:Body><u:X_SendIRCC xmlns:u="urn:schemas-sony-com:service:IRCC:1">"AAAAAQAAAAEAAAAvAw=="</u:X_SendIRCC></s:Body></s:Envelope>" -H 'Content-Type: text/xml; charset=UTF-8' -H 'SOAPACTION: "urn:schemas-sony-com:service:IRCC:1#X_SendIRCC"']])

And also the code here:

And this:

local socket = require "socket"
tcp = assert(socket.connect ("192.168.0.30", 20060))
tcp:send "*SCPOWR0000000000000001\n"
luup.sleep(50)
tcp:close()