mirror of
https://github.com/ShadowKatStudios/OC-Minitel.git
synced 2024-11-23 10:38:05 +11:00
added an option to not block in net.rsend
This commit is contained in:
parent
89b19e7808
commit
a85e2b01c2
@ -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
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user