1
0
mirror of https://github.com/ShadowKatStudios/OC-Minitel.git synced 2024-11-23 10:38:05 +11:00

microtel should actually work now

This commit is contained in:
Izaya 2018-03-29 23:40:06 +11:00
parent b82698aedc
commit 12ba096838
2 changed files with 6 additions and 4 deletions

View File

@ -1,6 +1,6 @@
function net.socket(address, port, sclose) function net.socket(address, port, sclose)
local conn = {} local conn, rb = {}, ""
local conn.state, conn.buffer, conn.port, rb, conn.address = "o", "", tonumber(port), "", address conn.state, conn.buffer, conn.port, conn.address = "o", "", tonumber(port), address
function conn.r(self,length) function conn.r(self,length)
rb=self.buffer:sub(1,l) rb=self.buffer:sub(1,l)
self.buffer=self.buffer:sub(l+1) self.buffer=self.buffer:sub(l+1)
@ -12,7 +12,7 @@ function net.socket(address, port, sclose)
function conn.c(s) function conn.c(s)
net.send(conn.address,conn.port,sclose) net.send(conn.address,conn.port,sclose)
end end
function net.hook[sclose](etype, from, port, data) function h(etype, from, port, data)
if from == conn.address and port == conn.port then if from == conn.address and port == conn.port then
if data == sclose then if data == sclose then
net.hook[sclose] = nil net.hook[sclose] = nil
@ -22,5 +22,6 @@ function net.socket(address, port, sclose)
conn.buffer = conn.buffer..data conn.buffer = conn.buffer..data
end end
end end
net.hook[sclose] = h
return conn return conn
end end

View File

@ -1,6 +1,7 @@
function net.listen(vport) function net.listen(vport)
local from,port,data
repeat repeat
local etype, from, port, data = computer.pullSignal(0.5) _, from, port, data = computer.pullSignal(0.5)
until port == vport and data == "openstream" until port == vport and data == "openstream"
local nport,sclose = math.random(2^15,2^16),tostring(math.random(-2^16,2^16)) local nport,sclose = math.random(2^15,2^16),tostring(math.random(-2^16,2^16))
net.send(from,port,tostring(nport)) net.send(from,port,tostring(nport))