There is a fundamental difference between streaming bytes with TCP and UDP...
- TCP communicates an EOF when it sees the end of the byte-stream
- UDP just stops sending data (i.e. it doesn't notify the other end of the data stoppage)
The consequences are that your TCP example works, but the UDP example doesn't because mplayer never knows when to process the bytes it is getting.
One way to solve this is with a timeout on both sides... First start your client with a timed finish (backgrounding the nc portion in a subshell so it won't block):
(nc -q 1 -u -l -p 65535 > [movie].avi&); sleep 10; fuser -k 65535/udp;\
mplayer [movie].avi; rm [movie].avi
Next start your server... in this case, I show it pushing the file to 192.168.12.238 on udp/65535
(cat [movie].avi | nc -u 192.168.12.238 65535&); sleep 10; \
fuser -n udp ,192.168.12.238,65535 -k
Finally, be sure you choose the timeout to be long enough to sequence the shell commands and finish the network transfer (which is normally rather quick, if you're on a wired ethernet LAN).