Edit: Just to be clear, that'd be:
$ nc -l $port | gzip -d > $filename $ cat $filename | gzip | nc $host $port