mirror of
https://github.com/ShadowKatStudios/OC-Minitel.git
synced 2024-11-27 04:18:05 +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 minitel = neo.requireAccess("x.svc.minitel","minitel daemon access")
|
||||||
local computer = neo.requireAccess("k.computer","pushing packets")
|
|
||||||
local event = require("event")(neo)
|
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
|
### 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.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
|
#### Layer 4
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
function returnNet(event,computer,minitel)
|
function returnNet(event,minitel)
|
||||||
|
|
||||||
local dbug = false
|
local dbug = false
|
||||||
|
local computer = {}
|
||||||
|
computer.uptime = os.uptime
|
||||||
|
|
||||||
function print(...)
|
function print(...)
|
||||||
if dbug then
|
if dbug then
|
||||||
@ -49,9 +51,10 @@ function net.usend(to,port,data,npID)
|
|||||||
minitel.sendPacket(0,to,port,data,npID)
|
minitel.sendPacket(0,to,port,data,npID)
|
||||||
end
|
end
|
||||||
|
|
||||||
function net.rsend(to,port,data)
|
function net.rsend(to,port,data,block)
|
||||||
local pid, stime = net.genPacketID(), computer.uptime() + net.streamdelay
|
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
|
repeat
|
||||||
_,rpid = svcpull("net_ack")
|
_,rpid = svcpull("net_ack")
|
||||||
until rpid == pid or computer.uptime() > stime
|
until rpid == pid or computer.uptime() > stime
|
||||||
@ -117,7 +120,7 @@ local function socket(addr,port,sclose) -- todo, add remote closing of sockets
|
|||||||
end
|
end
|
||||||
|
|
||||||
function net.open(to,port)
|
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 st = computer.uptime()+net.streamdelay
|
||||||
local est = false
|
local est = false
|
||||||
while true do
|
while true do
|
||||||
|
Loading…
Reference in New Issue
Block a user