socat gives "Resource temporarily unavailable" on OS X High Sierra
I am trying to create a virtual local com-port that forwards everything to a remote computer via TCP with this command:
sudo socat GOPEN:/dev/ptyp0,ignoreeof TCP:192.168.254.106:8080
2018/09/08 21:48:51 socat[10860] E open("/dev/ptyp0", 012, 0666): Resource temporarily unavailableThis is a freshly installed OS X High Sierra, so I doubt I am out of resources.
sudo lsof /dev/ptyp0Shows nothing... and I get the same result even if I try ptyp1, ptyp2 etc.
21 Answer
You can't just open a random pty and expect it to work. (Actually, you are supposed to open each of them in turn, until you find one that is free) Instead, use the proper socat syntax for it:
socat PTY,link=/tmp/mytty TCP:192.168.254.106:8080This will open the master side of an available pseudo-terminal, make a symlink under /tmp/mytty (modify as appropriate) to the slave side, and forward between the master side and your remote TCP port.
You can now use /tmp/mytty (or the slave-pty linked to from it) like a normal tty. ("Virtual local com-port" sounds suspiciously like a Windows term).
BTW, this will work on all platforms that support pseudo terminals, because socat uses the platform-appropriate method.
Edit
Whatever you see as an option in the Java program you run depends entirely on the Java program you run, which I don't know anything about (and you told us nothing about). It's entirely possible the Java program has additional options to tell it about other tty's. It's also possible it has no such options.
Files under /dev are part of a special filesystem called devfs which shows the devices available to the kernel. Apparently you are not allowed to create symlinks on it.
So if all your Java program does is to scan for files /dev/cu.*, then you are out of luck.
You can always try to find the source for your Java program, and change it. Or even patch the binary (replace the string /dev/cu by something else).
More in general
"Zoraya ter Beek, age 29, just died by assisted suicide in the Netherlands. She was physically healthy, but psychologically depressed. It's an abomination that an entire society would actively facilitate, even encourage, someone ending their own life because they had no hope. Th…"