Big Nuts Posted December 1, 2019 Share Posted December 1, 2019 Hello all, so i have been successful in getting data sent via export lua to an external program written in python. However having difficulty in getting information sent to dcs. The sends work ok, but it hangs with any attempt to receive. Been whacking my head against this wall for a few days. I've set timeouts to 0, tried no blocking, whatever i do i cannot seem to get data sent to dcs. Any tips or pointers appreciated. Afaik a call of accept() turns the socket into receive mode. [start Function] local socket = require("socket") TcpSocket= socket.try(socket.connect(IPAddress, Port)) TcpSocket:setoption("tcp-nodelay", true) socket.try(TcpSocket:send("FirstSocketCreated")) [update] socket.try(TcpSocket:send("Ping")) local client = TcpSock:accept() client.settimeout(10) local data, error = client:receive() Link to comment Share on other sites More sharing options...
BR55Sevas Posted December 1, 2019 Share Posted December 1, 2019 function LuaExportBeforeNextFrame() rs, err = mysocket:receive('*l') if (rs ~= nil) then _, _, pitch, bank = string.find(rs, "(.+) (.+)") LoSetCommand(2001, pitch) LoSetCommand(2002, bank) end end МиГ-29 Fly by wire СДУ Su-27SM second display panel https://www.youtube.com/embed/videoseries?list=PL_2GGwNpWNp_fKXfRtDhIk8s5Jf4a9XHS http://berkuts.ru Пилотажный сервер с роботом | Aerobatic server with PhantomControl Link to comment Share on other sites More sharing options...
Big Nuts Posted December 3, 2019 Author Share Posted December 3, 2019 Thank's got it working. For anyone else who may struggle, this is working; Very simple after all. function LuaExportStart() socket = require("socket") Sock = socket.try(socket.connect(IPAddress, Port )) Sock:setoption("tcp-nodelay", true) Sock:setoption("keepalive", true) end function LuaExportActivityNextEvent(t) local tNext = t socket.try(Sock:send("Ping")) data,err = Sock:receive() if data then socket.try(Sock:send(data)) end tNext = tNext + 5.0 return tNext end function LuaExportStop() if Sock then Sock.close() end end Link to comment Share on other sites More sharing options...
Recommended Posts