Typeerror: an integer is required

Asked

Viewed 31 times

0

Good Afternoon. I am programming a script with the socket library, struct and ctypes, to sniffing the packages on the network, but I’m having trouble in the section that passes the first 20 bytes of the package.

try:
    while True:
        raw_buffer = sniffer.recvfrom(65565)[0]
        ip_header = IP(raw_buffer[0:20])
        print ("Protocolo: %s %s -> %s" % (ip_header.protocol, ip_header.src_address, ip_header.dst_address))
  • 1

    What problem? Edit your question and include more details to clarify the problem.

  • Cod expects a whole and the informed type is not.

  • Probably the problem is when you try to instantiate the IP class, which expects an int, but is receiving a string, should change to IP(int(raw_buffer[0:20])), but they can be other things, since details are missing for a better analysis...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.