To build a port scanner in Python requires, at its most basic, just the
socketmodule. However, with the modules sys and optparse, you can build a very servicable port scanner that will help you debug your network applications or check for security issues on your network. Unlike tools such as nmap, this one allows you to tailor the output to your needs and, if necessary, easily port it to other applications for further processing. See the new series "A Python-Powered Port Scanner" for more.