Reputation: 41
host = gethostbyname(gethostname())
NameError: name 'gethostbyname' is not defined
I need some help, can't figure out what's amiss
Here is the code:
conn = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.ntohs(3)) host = gethostbyname(gethostname()) conn.bind((host, 80)).
I am trying my hands on a simple packet sniffer in Python.
Upvotes: 1
Views: 2390
Reputation: 13520
You have to firstly import the socket.gethostbyname
function as:
from socket import gethostbyname
Then your code
Upvotes: 2