ehmmm obviously depends by the context where you want to apply this delay.
for example in a multi-thread environment (like a tcp server) the usage of sleep() blocks the thread and not the whole program.
while in other fields this can be far from being easy.
imagine the delaying of sendto which obviously is not possible with a simple sleep() but requires to buffer the packet(s) and sending it when the whole loop of the function reaches the desired time.
and this is the same also if you use a proxy, the only thing which changes is that if you can't modify the source of the main program you can modify the proxy.
anyway I implemented this thing in a basic and quick way (based on the number of packets and not on the elapsed time) as a plugin for proxocket, maybe take a look at it:
sendto-lagger-t856.html