Listening on port being used
Question: Is there any way to listen to traffic on a specific port that another program
is currently using, through the python `socket` module? For example:

    
    
                               |--> my program
    external request -> Host ->|--> intended program
    

I am not looking to send back a response to the request, I simply want the
traffic. I was looking at using the `socket.SO_REUSEADDR` method, but I think
that's simply to avoid having to wait for the socket's timeout, not to allow
another listener.


Answer: You can do that with [scapy](http://www.secdev.org/projects/scapy/)

see <http://www.secdev.org/projects/scapy/doc/usage.html#sniffing>

to use it in your own python program, you'd have to import the sniff command

    
    
    from scapy.all import sniff
    a=sniff("tcp and port 1337")
    

sniff has various options (callback functions, timeout, number of packets etc)

