Say I have a Node.js tcp server:
const map = new Map();
const s = net.createServer(function(socket){
socket.pipe(jsonParser()).on('data', function(v){
v && v.pid && map.set(v.pid, socket);
}):
});
I connect to it using Bash like so:
exec 3<>/dev/tcp/localhost/9091 # persistent file descriptor
exit_code=$?
if [[ ${exit_code} -ne 0 ]]; then
echo "could not connect to daemon";
exit;
fi
echo "{\"pid\":${BASH_PID},\"args\":[${ARGS}],\"cwd\":\"$(pwd)\"}" >&3
my question is - do I have to wait for the first message from the socket to know more information about the socket? Or is there some way to get the information upon first connection, without having to listen to data being written to/from the socket?