This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

copas connecting to tcp server cannot receive percentage
#1
Hi,

Ok so I have a resident script using a copas udp server on the localhost to receive commands from knx objects (event script) , then there is a copas tcp client connecting to an tcp server on the local network. I did it this way so they don't block each other.  The issue I am experiencing is that when the tcp server sends out an percentage character the tcp client stops receiving anything else from the server.

Does someone have an idea?

Thanks,

Roger

Code:
if not ready then
 socket = require("socket")
 copas = require("copas")
 alert('not Ready')
 ready=true
 
 function parse(data)
   alert('parsing...  '..data)
 end
   
 function fromKNX(command)
  alert('from KNX.. '..command)
 end
 
 local server = socket.udp()
 server:setsockname("127.0.0.1",23456)
 function handler(skts)
   skts = copas.wrap(skts)
   alert("UDP connection handler")
   while true do
     local s, err
     alert("UDP receiving...")
     s, erro = skts:receive(2048)
     if not s then
       alert("UDP Receive error: ", erro)
       break
     end
     alert("Received data, bytes: "..s)
     fromKNX(s)
   end
 end
 copas.addserver(server, handler, 1)  
end

if not skt then
 alert('not socket')
 if skt then
   skt:close()
   skt = nil
 end
 -- create tcp client
 skt, err = socket.connect('10.10.10.41', 4999)
 skt:settimeout(0)
 copas.addthread(function()
     while true do
      local resp,err = copas.receive(skt)
       if not resp then
         alert("TCP Receive error: ", err)
         break
       end
       parse(resp)
     end
   end)
 -- connect ok, reset buffer
 if skt then
   alert('[tcp-client] connection ok')
   warningfailed = true
   init()
   -- error while connecting,
 else
   if warningfailed then alert('[tcp-client] connection failed (conn): %s', err) end
   warningfailed = false
 end  
end

copas.loop()
Reply


Messages In This Thread
copas connecting to tcp server cannot receive percentage - by rocfusion - 14.06.2017, 07:30

Forum Jump: