Skip to content

Commit

Permalink
Network stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
nagolove committed Jan 23, 2020
1 parent ac6a780 commit 8847418
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ local pallete = require "pallete"
]]--
--local ntwk
if netLogging then
ntwk = require "ntwk".new("visualdoj.ru", 10081)
ntwk = require "ntwk".new("visualdoj.ru", 10081, true)
--ntwk = require "ntwk".new("127.0.0.1", 10081)
else
--ntwk = require "ntwk".dummy()
Expand Down
16 changes: 6 additions & 10 deletions ntwk/cmdthread.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,12 @@ local host, port = chan:pop(), chan:pop()
print("cmd host", host, "port", port)

local conn = socket.tcp()
--conn:setoption("keepalive", true)
local ok, msg, tmsg
local finish = false
local ok, errmsg

--conn:settimeout(0.1)
--conn:settimeout(10)

local ok, errmsg
--conn:setoption("keepalive", true)

function connect()
--if conn then conn:close() end
Expand Down Expand Up @@ -96,17 +94,15 @@ repeat
if ok then
local data, err, partial = conn:receive("*l")
print("data", data, "err", err, "partial", partial)
if err == "closed" then
--if err == "closed" then
if err then
print("err", err)
ok = nil
--conn:close()
--connect()
ok = false
conn = nil
end
local procedure = actions[data]
if procedure then
procedure(conn)
--else
--error(string.format("Unknown command %s", action))
end
end
until false
Expand Down
3 changes: 3 additions & 0 deletions ntwk/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ function client.new(host, port, logonly)

setmetatable(self, client)

print("client.new()", host, port)
self.logchan:push("isworking?")

self.logchan:push(host) self.logchan:push(port + 1)
self.logThread:start()

Expand Down

0 comments on commit 8847418

Please sign in to comment.