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.