diff --git a/Embedded/microtel-5-core.lua b/Embedded/microtel-5-core.lua index 2c32fa9..419befc 100644 --- a/Embedded/microtel-5-core.lua +++ b/Embedded/microtel-5-core.lua @@ -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 diff --git a/Embedded/microtel-5-listen.lua b/Embedded/microtel-5-listen.lua index 59b1158..8f3087f 100644 --- a/Embedded/microtel-5-listen.lua +++ b/Embedded/microtel-5-listen.lua @@ -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))