How can I make packet sniffer at selected server and port? Something like Wpe Pro or RPE, but I want to use Python and 'print' for writing these packets. I tried this:
import socket
UDP_IP = "xx.xx.xx.xx"
UDP_PORT = xxxx
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))
while True:
data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
print("received message:", data)
but I think it can't work (UDP or something else is wrong?). How can I do it correctly?
I have working code that sends then receives and it goes a little something like this:
Could it be the case that
settimeout
is missing for you?