what happens if the packet with the size of the record is lost ?
what happens if the packet with the size of the record is lost ?
From brazil (:
Pascal pownz!
Sorry, but I'm not sure what you mean...Originally Posted by arthurprs
cheers,
Paul
Games:
Seafox
Pages:
Syntax Error Software itch.io page
Online Chess
http://gameknot.com/#paul_nicholls
opz, sorry my english.Originally Posted by paul_nicholls
let me try again,
what happens if the size of the record (that will be send after its size) is lost?
ps: im saying this cuz i read somewhere that UDP can lose some data
From brazil (:
Pascal pownz!
It's not common that udp looses some random bits in the packet, either the packet is lost or not.Originally Posted by arthurprs
To avoid some nasty crashes with lost packets make shure that you keep the data amount in each packet to less then the UDP framesize (sadly it varies depending on the network type), then you wont have to wory about getting to little data.
If you want to send larger packets you have to code around this, make shure the length of the incomming data is larger then the length of the stream. If it's not you have to append the next packet that arrives to the stream.
What you probably going to need then is some kind of sequencing so you can detect when the 2nd packet is lost, else you will get incorrect data for the next packet.
Writing theese algoritms is big task, i would recommend using something like ENet where theese things are already written
Amnoxx
Oh, and this code appears to be an approximate replacement for return(random() & 0x01);
Phoenix Wiki
http://www.phoenixlib.net/
Phoenix Forum
http://www.pascalgamedevelopment.com/viewforum.php?f=71
thanks =)Originally Posted by Andreaz
From brazil (:
Pascal pownz!
A little inspired by this topic started making my own network "wrapper". I'm using WSockets 1.20 http://www.delphi32.com/vcl/2142/ for it, to support TCP and UDP server and client in a single class. Constructing 1 of this class makes 1 connection which does few of following (still in construction ofc):
- Unified server and client code, making it less significant for programmer to deal with
- TCP or UDP you choose, engine don't care
- String masked whole packet encryption (optional custom encryption in addition if you want to do it hard/more secure way)
- List of clients who joined the network properly, seen by all connections
- Queue system to verify no lost packets (this is handled within Update function similar to DelphiX direct input). Packets are stored and resent when needed.
- Sending from 1 connection to other or broadcasted to all, including self
- Ping checking
- Optional Checksum for making sure packets don't get damaged, maybe useful for file transfer
As for mechanics how TCP and UDP can use same kind of packets, i use a large, say 40000 bytes+header structure (noone should ever use that big) in memory where WSockets writes only the amount of incoming data through onData event. It has a ReadBuffer() function which returns number of bytes received. This temporary packet is a variable within class to prevent slowing that would happen if packet was created within procedure every time. Found out this is the logic how TUDPClient read dynamic strings too. If i had sent packet size first and packet after it in separate packets, i'd risk them coming in different order or disappearing on the way, which could entirely hang the network (imagine 4 clients send the 2 packets same time).
And as any other of my projects, they either finish or not, without any time limits... it is far already though.
Bookmarks