Any reliable UDP network libraries available for PB?
Posted: Sun Mar 25, 2012 11:47 pm
Hey all, has anyone developed or created a wrapper for any UDP network layers that feature reliable packets?
http://www.purebasic.com
https://www.purebasic.fr/english/
UDP is not reliable. it's one way....Nituvious wrote:Hey all, has anyone developed or created a wrapper for any UDP network layers that feature reliable packets?
You can write a routine to keep track of all packets and require acknowledgement of their arrival. I am just wondering if there are any libraries that already do this or even a wrapper of such a library.jassing wrote:UDP is not reliable. it's one way....Nituvious wrote:Hey all, has anyone developed or created a wrapper for any UDP network layers that feature reliable packets?
I wrote syslog server reading udp; I don't think you need any special 'wrappers'.
Code: Select all
Structure ms
active.b
somedata.b
EndStructure
Structure fs
id.l
somedata.b
EndStructure
NewMap mymap.ms()
Dim myarray.fs(5)
clientid = 33834
myarray(3)\id = clientid
mymap(Str(clientid))\active = 1
mymap(Str(clientid))\somedata = 34
If mymap(Str(clientid))\active = 1 ; check if client is valid
Debug mymap(Str(clientid))\somedata
EndIf
For i = 0 To ArraySize(myarray())
If (myarray(i)\id = clientid)
Debug myarray(i)\somedata
Break
EndIf
Next iWhich defeats the purpose of UDP. UDP is only faster than TCP because it isnt reliable. If you add reliability you end up with the same speed as TCP, maybe even slower depending on your implementation.Nituvious wrote:You can write a routine to keep track of all packets and require acknowledgement of their arrival. I am just wondering if there are any libraries that already do this or even a wrapper of such a library.jassing wrote:UDP is not reliable. it's one way....Nituvious wrote:Hey all, has anyone developed or created a wrapper for any UDP network layers that feature reliable packets?
I wrote syslog server reading udp; I don't think you need any special 'wrappers'.
But that still doesnt change reliability. You have to send back a answer befor you go on with the program, else you dont know if a packet was lost or corrupted. Even worse they could come in in the wrong order. Just logging what packets come in does not change reliability.Nituvious wrote:Sending a packet and keeping a record of it does not slow down UDP. Stopping everything when a packet is lost does, this is why I do not want to use TCP.