Thread: using netstat

  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Rep Power

    using netstat

    Hi All,

    I'm new to python and I have a problem to solve using python:

    Basically, I want to write a small program, which runs on a designated port, and returns a complete listing of all network connections (using netstat) back to the designated port.

    From my limited experience with Python I assume I need to:
    1. import socket library
    2. create a stream socket
    3. open a specific port for connections
    4. tell the socket to wait & listen for clients
    5. during this time I accept client connections & grab network info using netstat
    6. close the connection when done

    Any help would be gratefully appreciated.

  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Hull, UK
    Rep Power
    Makes sense, you could also create a web service although thats probably overkill depending on what your doing. In either case you should use the subprocess module to get the results from 'netstat'. Here are a few links that you might find useful:

    If you have any questions ask away,

    programming language development: Hula

  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    London, England
    Rep Power
    Alternatively you could run it as an XML-RPC service. This would enable you to use SimpleXmlRpcServer to handle all the low-level code, and it would be callable from any language that supported XML-RPC.

    DAve - The Developers' Coach

IMN logo majestic logo threadwatch logo seochat tools logo