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.

localhost socket stuck with specific data ?
#4
Try this. It will try sending the data again if the first send call failed due to a closed socket or any other error. Remove log() calls once you get it working.
Code:
if not server then
  require('user.lutron')
  require('socket')

  server = socket.udp()
  server:setsockname('127.0.0.1', 5485)

  function send(data)
    if not sock then
      sock, err = lutron_login()

      if not sock then
        log('lutron login failed', err)
      end
    end

    if sock then
      res, err = sock:send(data)

      if res then
        return true
      end

      log('lutron send failed', err)

      sock:close()
      sock = nil
    end
  end
end

data = server:receive()
if data then
  if not send(data) then
    send(data)
  end
end
Reply


Messages In This Thread
RE: localhost socket stuck with specific data ? - by admin - 18.07.2024, 12:55

Forum Jump: