1. Home
  2. Computing & Technology
  3. Python

Python-Powered Port Scanner

From Al Lukaszewski, for About.com

1 of 4

Introduction

One of the most common parts of network debugging and security testing is port checking. Whether your application is supposed to use a given port, as in P2P or server-client relations of different protocols, or whether you are sweeping for an opening on your network, being able to automate the checking of ports on a set of servers is a helpful facility to have.

This tutorial guides you through building a port scanner in Python using three modules: sys, optparse, and socket. The first is for cleanly exiting the program. The second is for enabling options (aka "flags") on the command line. The third is the base level module for network programming in Python. The brains of the program will rely simply on opening and connecting to a socket via TCP.

Explore Python
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Python
  4. Networking
  5. Learn Python - Network Programming - Port Scanning - Python-Powered Port Scanner

©2009 About.com, a part of The New York Times Company.

All rights reserved.