Networking in C · advanced · ~10 min
Detect which loopback (local) ports accept a TCP connection.
A "scan" is simple: it tries to connect() to each port, one at a time.
ECONNREFUSED), nothing is listening there.That is the whole idea. You learn what is running by seeing which connection attempts go through.
Scanning hosts you do not own is risky, and not just technically.
Scanning third-party hosts without explicit, written authorisation counts as unauthorised access in many jurisdictions. In other words, it can be illegal.
The platform's exercises only ever target 127.0.0.1 (the loopback address, which always points back to your own machine). They run against test servers ("fixtures") that the exercise harness opens itself.