Page 1 of 1

Any reliable UDP network libraries available for PB?

Posted: Sun Mar 25, 2012 11:47 pm
by Nituvious
Hey all, has anyone developed or created a wrapper for any UDP network layers that feature reliable packets?

Re: Any reliable UDP network libraries available for PB?

Posted: Sun Mar 25, 2012 11:54 pm
by jassing
Nituvious wrote:Hey all, has anyone developed or created a wrapper for any UDP network layers that feature reliable packets?
UDP is not reliable. it's one way....
I wrote syslog server reading udp; I don't think you need any special 'wrappers'.

Re: Any reliable UDP network libraries available for PB?

Posted: Mon Mar 26, 2012 12:23 am
by Nituvious
jassing wrote:
Nituvious wrote:Hey all, has anyone developed or created a wrapper for any UDP network layers that feature reliable packets?
UDP is not reliable. it's one way....
I wrote syslog server reading udp; I don't think you need any special 'wrappers'.
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. :|

Re: Any reliable UDP network libraries available for PB?

Posted: Tue Mar 27, 2012 5:14 am
by Nituvious
Question to any PB guru: if I were to store client id as a map, would this make it faster or slower than an array or list to access and modify?

For example, which would be faster?

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 i

Re: Any reliable UDP network libraries available for PB?

Posted: Tue Mar 27, 2012 5:32 am
by jassing
I'm no guru -- but it be simple enough to do a few things in a loop and time each method to see which is fastest.

However, I suspect all will be similar; and any edge may be lost on another system with different specs.

Re: Any reliable UDP network libraries available for PB?

Posted: Thu Mar 29, 2012 8:38 am
by Thorium
Nituvious wrote:
jassing wrote:
Nituvious wrote:Hey all, has anyone developed or created a wrapper for any UDP network layers that feature reliable packets?
UDP is not reliable. it's one way....
I wrote syslog server reading udp; I don't think you need any special 'wrappers'.
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. :|
Which 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.

If you need reliability go with TCP.

Re: Any reliable UDP network libraries available for PB?

Posted: Sat Mar 31, 2012 1:31 am
by Nituvious
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.

Re: Any reliable UDP network libraries available for PB?

Posted: Sat Mar 31, 2012 8:50 am
by Thorium
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.
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.

UDP should be used if it is no problem if packets get missing. Like for player position updates in a game. Doesnt matter if one of the updates gets lost.