Testing if a firewall blocks a port
Posted on 2003-03-03
I would like to write a small module that tests if a firewall is blocking a port. For instance, my main application requires that the SQL server port is open. If a firewall is blocking the port, my application hangs. I'd like to exit gracefully and notify the user to open the port.
I seem to remember a really long time ago writing a winsock application that has the server listening on a port. I was writing on Unix and I had the server fork a child process. If the child process is blocked from connecting to the parent's listening port, the parent will kill everything after a certain amount of time.
Is this method sound and what's the Windows equivalent of fork()? CreateThread? If anyone can direct me to a sample code of something like this (usually it's separate server/client programs), I'd appreciate it.