27 lines
718 B
Lua
27 lines
718 B
Lua
tA = {...}
|
|
local h,p = tA[1], tonumber(tA[2])
|
|
local function nshcw(h,p)
|
|
while true do
|
|
local sI = os.getenv("sI")
|
|
local ev = {event.pull()}
|
|
if ev[1] == "net_msg" and ev[2] == h and ev[3] == p and ev[4]:sub(1,1) == "d" then
|
|
write(ev[4]:sub(2))
|
|
elseif ev[1] == "net_msg" and ev[2] == h and ev[3] == p and ev[4]:sub(1,1) == "\27" then
|
|
break
|
|
elseif ev[1] == "key" and ev[2] == sI then
|
|
net.send(h,p,string.char(ev[3],ev[4]))
|
|
end
|
|
end
|
|
end
|
|
net.send(h,p or 23,"initnsh2")
|
|
local bt = os.time()
|
|
local tp,src,port,msg
|
|
repeat
|
|
tp, src, port, msg = event.pull()
|
|
until (tp == "net_msg" and src == h and port == p) or os.time() > bt+16
|
|
if tp == "net_msg" then
|
|
nshcw(h,tonumber(msg))
|
|
else
|
|
print("timeout.")
|
|
end
|