I am writing a docker client in Node.js. It must connect to unix domain socket /var/run/docker.sock
if it exists or fallback to TCP
socket, typically tcp://localhost:2375
(when client is running on Windows).
The question is - How can I verify the presence of domain socket before falling back to TCP
socket?
I can probably check for the presence of TCP socket as mentioned in this answer or attempt to connect to the domain socket. But that does not look clean.