I want to run socat as a server - against a target that will go up and down intermittently (cloud microservice environment). I want socat to listen - and open the port when it gets a listener connection.  (A socat server)My question is: Is there a way to make socat not open the target connection until it receives a listener connection?
Is there a way to make socat not open the target connection until it receives a listener connection?
port forwarding;socat
This is the default, if I understand your question. The first socket is opened and blocks in listen. Only when a connection is made will the second-named connection be attempted. You can test this. E.g. listen on port 60127 and connect to port 60128 in one shell:$ socat tcp-l:60127,reuseaddr tcp:localhost:60128It will block waiting.  In another shell try to connect:$ telnet localhost 60127Trying 127.0.0.1...Connected to localhost.Escape character is '^]'.Connection closed by foreign host.It fails, and the original command fails too:socat[30293] E connect(3, AF=2 127.0.0.1:60128, 16): Connection refusedIf, however, you repeat the first socat, then add another on port 60128 with:$ socat tcp-l:60128,reuseaddr -then the telnet will work. So, clearly the first socat does not try the second-named connection until needed.