When I'm opening a network connection in Python like
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('www.heise.de', 80))
I can read the connection state from the console:
netstat --all --program|grep <PID>
tcp 0 0 10.10.10.6:39328 www.heise.de:http VERBUNDEN 23829/python
But how can I read this connection state, CONNECTED, CLOSE_WAIT, ... from within Python? Reading through the socket documentation didn't give me any hint on that.