Jump to content

how to open and clock lua socket?


karpiyon

Recommended Posts

Hi,

I'm trying to follow the example and read the data from a socket.

I'm using this example below but when my add (it a plugin for VA) is not running the connection is closed and i cannot restore it.

 

How can I open a connection which will not close or try to reopen itself if closed?

 

 

function LuaExportStart()
package.path  = package.path..";"..lfs.currentdir().."/LuaSocket/?.lua"
package.cpath = package.cpath..";"..lfs.currentdir().."/LuaSocket/?.dll"
socket = require("socket")
IPAddress = "127.0.0.1"
Port = 31090
MySocket = socket.try(socket.connect(IPAddress, Port))
MySocket:setoption("tcp-nodelay",true) 
end

function LuaExportBeforeNextFrame()
end

function LuaExportAfterNextFrame()

local IAS = LoGetIndicatedAirSpeed()

socket.try(MySocket:send(string.format("IAS: %.4f \n",IAS)))
end

function LuaExportStop()

if MySocket then 
	socket.try(MySocket:send("exit"))
	MySocket:close()
end
end

function LuaExportActivityNextEvent(t)
end

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...