diff --git a/OpenOS/README.md b/OpenOS/README.md index 2c27799..4989752 100644 --- a/OpenOS/README.md +++ b/OpenOS/README.md @@ -45,7 +45,7 @@ The net library provides an easy way of interacting with the minitel daemon, and *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 diff --git a/OpenOS/usr/lib/net.lua b/OpenOS/usr/lib/net.lua index d8445e1..2eccf4b 100644 --- a/OpenOS/usr/lib/net.lua +++ b/OpenOS/usr/lib/net.lua @@ -19,9 +19,10 @@ function net.usend(to,port,data,npID) computer.pushSignal("net_send",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) + if block then return false end repeat _,rpid = event.pull(0.5,"net_ack") until rpid == pid or computer.uptime() > stime