mirror of
https://github.com/ShadowKatStudios/OC-Minitel.git
synced 2024-12-26 02:08:07 +11:00
update the KOS NEO versions of the core stuff
This commit is contained in:
parent
658f87e37c
commit
27bc1c6fc3
@ -24,13 +24,12 @@ Due to how KittenOS's security model works, you have to initialise the library i
|
||||
|
||||
```
|
||||
local minitel = neo.requireAccess("x.svc.minitel","minitel daemon access")
|
||||
local computer = neo.requireAccess("k.computer","pushing packets")
|
||||
local event = require("event")(neo)
|
||||
|
||||
local net = require("net")(event,computer,minitel)
|
||||
local net = require("net")(event,minitel)
|
||||
```
|
||||
|
||||
This gives access to the event API, computer API and Minitel service to the net library.
|
||||
This gives access to the event API and Minitel service to the net library.
|
||||
|
||||
### API
|
||||
|
||||
@ -42,7 +41,7 @@ Being a direct port of the OpenOS version, the API is the same.
|
||||
|
||||
*net.usend(host, port, data, pid)* - Sends an unreliable packet to *host* on *port* containing *data*, optionally with the packet ID *pid*.
|
||||
|
||||
*net.rsend(host, port, data)* - Sends a reliable packet to *host* on *port* containing *data*.
|
||||
*net.rsend(host, port, data, block)* - Sends a reliable packet to *host* on *port* containing *data*. If *block* is true, don't wait for a reply.
|
||||
|
||||
#### Layer 4
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
function returnNet(event,computer,minitel)
|
||||
function returnNet(event,minitel)
|
||||
|
||||
local dbug = false
|
||||
local computer = {}
|
||||
computer.uptime = os.uptime
|
||||
|
||||
function print(...)
|
||||
if dbug then
|
||||
@ -49,9 +51,10 @@ function net.usend(to,port,data,npID)
|
||||
minitel.sendPacket(0,to,port,data,npID)
|
||||
end
|
||||
|
||||
function net.rsend(to,port,data)
|
||||
function net.rsend(to,port,data,block)
|
||||
local pid, stime = net.genPacketID(), computer.uptime() + net.streamdelay
|
||||
computer.pushSignal("net_send",1,to,port,data,pid)
|
||||
minitel.sendPacket(1,to,port,data,pid)
|
||||
if block then return pid end
|
||||
repeat
|
||||
_,rpid = svcpull("net_ack")
|
||||
until rpid == pid or computer.uptime() > stime
|
||||
@ -117,7 +120,7 @@ local function socket(addr,port,sclose) -- todo, add remote closing of sockets
|
||||
end
|
||||
|
||||
function net.open(to,port)
|
||||
net.rsend(to,port,"openstream")
|
||||
if not net.rsend(to,port,"openstream") then return false, "no ack from host" end
|
||||
local st = computer.uptime()+net.streamdelay
|
||||
local est = false
|
||||
while true do
|
||||
|
Loading…
Reference in New Issue
Block a user