1
0
mirror of https://github.com/ShadowKatStudios/OC-Minitel.git synced 2024-11-23 02:28:05 +11:00

added an option to not block in net.rsend

This commit is contained in:
Izaya 2018-07-25 12:29:25 +10:00
parent 89b19e7808
commit a85e2b01c2
2 changed files with 3 additions and 2 deletions

View File

@ -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.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

View File

@ -19,9 +19,10 @@ function net.usend(to,port,data,npID)
computer.pushSignal("net_send",0,to,port,data,npID) computer.pushSignal("net_send",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) computer.pushSignal("net_send",1,to,port,data,pid)
if block then return false end
repeat repeat
_,rpid = event.pull(0.5,"net_ack") _,rpid = event.pull(0.5,"net_ack")
until rpid == pid or computer.uptime() > stime until rpid == pid or computer.uptime() > stime