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.
You have to firstly import the socket.gethostbyname
function as:
from socket import gethostbyname
Then your code
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.