#!/bin/bash
usage="Usage: $0 udpport tcpport"
udpport=${1?$usage}
tcpport=${2?$usage}
fifo_parent=$(mktemp --tmpdir=/tmp -d udptotcp.XXXX)
fifo=$fifo_parent/fifo
mkfifo $fifo
[[ ! -p $fifo || ! -r $fifo || ! -w $fifo ]] && { echo 'Fifo could not be made or does not have the right perms'; exit 1; }
echo 'starting nc'
nc -l -u $udpport < $fifo | nc 127.0.0.1 $tcpport > $fifo
echo 'cleaning up'
rm -f $fifo
rmdir $fifo_parent

