mirror of
https://github.com/AR2000AR/openComputers_codes.git
synced 2025-09-09 07:01:14 +02:00
[network] nc
This commit is contained in:
@@ -18,7 +18,9 @@ opts.p = tonumber(opts.p)
|
|||||||
local function listenSocket(listenedSocket)
|
local function listenSocket(listenedSocket)
|
||||||
repeat
|
repeat
|
||||||
local msg = listenedSocket:reciveString()
|
local msg = listenedSocket:reciveString()
|
||||||
if (msg) then print(msg) end
|
if (msg) then
|
||||||
|
term.write(msg)
|
||||||
|
end
|
||||||
os.sleep()
|
os.sleep()
|
||||||
until not listenedSocket:isOpen()
|
until not listenedSocket:isOpen()
|
||||||
end
|
end
|
||||||
@@ -68,7 +70,7 @@ elseif (opts.u) then --connect UDP
|
|||||||
listenerThread = thread.create(listenSocket, socket)
|
listenerThread = thread.create(listenSocket, socket)
|
||||||
repeat
|
repeat
|
||||||
local msg = term.read()
|
local msg = term.read()
|
||||||
if (msg) then socket:send(msg) end
|
if (msg) then socket:send(msg .. "\n") end
|
||||||
until not msg or not socket:isOpen()
|
until not msg or not socket:isOpen()
|
||||||
socket:close()
|
socket:close()
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user