I’ve got a file descriptor that points to a socket (example code below).
exec 3<>/dev/tcp/localhost/9999
echo -e "Some Command\n" >&3
Sometimes that socket closes and needs to be re-opened (a restart of the server).
How can I test if the socket (fd #3 in this case) is writable?
The echo will always succeed, regardless of whether the socket has been closed already or not.
Solution is the feedback from the server.
When you send a request to the server, it needs to answer to it.
EDIT:
using netcat to determine is the port is open