how do I specify a path for a socket.tcp call

I’ve got my Vera kicking off a task on another machine via URL. The remote machine sometimes takes a while to respond and timeout doesn’t appear to work for Lua’s socket.http library.

I found this example that uses sockets:
http://forum.micasaverde.com/index.php/topic,11182.msg79566.html#msg79566

I can specify host and port, cribbing from the example and the Lua manual, but I don’t understand enough to know where to include the path.

Can anyone help me out? The path doesn’t appear to be what I should send via the tcp.send “message” value.

I’ve got :

	local host = "192.168.1.101"
	local path = "/bin/SET;&html_list()?$Office_CD_Lamp=OFF"

	local socket = require("socket")
	local tcp = assert(socket.tcp())
	if( tcp ~= "nil" and tcp ~= nill) then
	  tcp:settimeout(1)
	  tcp:connect(host, 8080)
	  tcp:send(path .. "\r")
	  tcp:close()
	end

This is one example of how I do something similar:

luup.inet.wget("http://192.168.2.1:8086/?x10command=DEVICE~sendplc~%22C1%20ON%22")

or something more detailed

[code]–=====================================================================
–Update x10 Switches By Polling
–======================================================================
–Check Boiler G13
local serverurl=(“http://192.168.2.1:8086/?x10command=~queryplc~”)
local switchaddress=(“%22G13%20ON%22”)
local fullcommand=(serverurl … switchaddress)

local http = require(“socket.http”)
result, status = http.request(fullcommand)

local switchstate = result:match(" Line:(%d+)")

if (switchstate == “100”) then
switchstate = “1”
luup.call_action(“urn:upnp-org:serviceId:VSwitch1”, “SetTarget”, {newTargetValue = “1”}, 48)
else
switchstate = “0”
luup.call_action(“urn:upnp-org:serviceId:VSwitch1”, “SetTarget”, {newTargetValue = “0”}, 48)
end[/code]

Thanks @konradwalsh, but neither inet.wget nor socket.http honor a timeout setting.

I should have been clearer that I want to set a really short timeout so that Vera doesn’t wait very long. I basically want to tap the external URL and not wait for a response.

I’m pretty sure that’s done at the end of the path… Include this…
,5 for 5 seconds

E.g

(“Http://IP/path”, 5)

Sent from my GT-N7100 using Tapatalk

Opening a socket is a LOW-LEVEL communication protocol.
If by PATH you mean a URL that is a high level protocol … which ultimately calls the low level protocol … after doing a lot of work.

See:
http://forum.micasaverde.com/index.php/topic,21763.msg153655.html#msg153655

If you want to make an http request.

The problem I’m seeing with socket.http is that it appears to ignore the timeout. I’ve got http.TIMEOUT = 1, but it appears to me that Vera is waiting more than a second for the URL to finish loading. I don’t need a response - I just want to “tap” the external URL to trigger activity on another machine. Maybe I’m misreading the symptoms?

You have to wait until the connection … otherwise with too short of a timeout … it will about the connection.
Timeouts are set differently via the different layers in the network stack.