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

View File

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