Netcat (nc) can be use as a mini server which can listen to either tcp or udp port on Mac or Linux.
nc – listen on a tcp port
Use sudo in case port is privileged (less than 1024).
$ nc -l 8080
nc – listen on a udp port
Use sudo in case port is privileged (less than 1024).
$ nc -u -l 8080