I am using macOS 13 (Ventura) and have tried your command:
nc -lnvp 1234 > filename.log
And it fails with an error that states:
nc: missing port with option -l
Trying the same command without the -p option like this works fine:
nc -lnv 1234 > filename.log
Checking the man page for nc (aka: man nc) in macOS shows this:
-l Used to specify that nc should listen for an incoming connection
rather than initiate a connection to a remote host. It is an
error to use this option in conjunction with the -p, -s, or -z
options. Additionally, any timeouts specified with the -w option
are ignored.
Note where it clearly states the following:
“It is an error to use this option in conjunction with the -p, -s, or -z options.”
So that’s the issue; don’t set the -p option and your command will work fine and port 1234 will be used.