My mistake, and you different, my code running on a Windows system reported error, and there is No Way Out. The error is: OSError: [WinError 10022]
import socket, sys, time, os def tcpsniffer(): s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_TCP) while True: packet = s.recvfrom(1024) print('recvfrom packet!') if __name__ == '__main__': tcpsniffer()