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:
parent
b82698aedc
commit
12ba096838
@ -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
|
||||||
|
@ -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))
|
||||||
|
Loading…
Reference in New Issue
Block a user