On Mon, Jul 21, 2008 at 1:25 PM, Rupp, Romaine <[EMAIL PROTECTED]> wrote: > Hello, > > I am new to programming with python and sockets. > > I would like to determine the status of a socket as it is returned when you > do 'netstat –a | grep <port#>'. I would like to know if the socket state > is ESTABLISHED, LISTEN , CLOSE_WAIT, etc. > > Is there a way to get this information through a socket call? > > I've tried using socket.getperrname() function, but that only tells if there > is a connection. > > Is there a way to get more information on the state of the socket > connection? >
If you're on linux, you could try poking around /proc/net. See, for example: http://www.linuxdevcenter.com/pub/a/linux/2000/11/16/LinuxAdmin.html But I think invoking netstat and parsing the output from python might work well enough. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor