Listen for all incoming traffic on port

Rob picture Rob · Mar 3, 2016 · Viewed 8.4k times · Source

With python, I have compiled the following script:

from socket import *

socket = socket(AF_INET, SOCK_DGRAM)
socket.bind(("127.0.0.1", 80))
while True:
    data, addr = socket.recvfrom(1024)
    print addr[1]

It is supposed to receive all incoming traffic from port 80. However, if I load a webpage, it does not lot anything. Is there a problem with my script?

Answer

JA Gonçalves picture JA Gonçalves · Sep 27, 2017

There seem to be some misconceptions here, and wanted to make clear for future visitors. When you visit a website you don't send packets out of port 80, you send packets from a random port to the port 80 of a different machine. In this case you are expecting to have packets on your port 80 when you are visiting website: this can't happen. This would only apply if you are hosting a website or listening on that port.