Map port to process

Diez B. Roggisch deets at nospam.web.de
Thu Jan 5 11:05:02 EST 2006


py wrote:

> Is there a way in python to figure out which process is running on
> which port?  I know in Windows XP you can run "netstat -o" and see the
> process ID for each open port....but I am looking for something not
> tied to windows particularly, hopefully something in python.
> 
> if not, any known way, such as netstat shown above, for other versions
> of windows (such as 98, 2000) and even linux?

Linux also knows netstat.

And at least with on-board mechanisms (meaning the standard lib), I fear you
can only try and use netstat as subprocess.

I'm not aware of an extension module that does what you want, but I didn't
google for it.

Diez



More information about the Python-list mailing list