[英]NameError: name 'gethostname' is not defined
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. 我正在尝试使用Python中的简单数据包嗅探器。
You have to firstly import the socket.gethostbyname
function as: 您必须首先将
socket.gethostbyname
函数导入为:
from socket import gethostbyname
Then your code 然后你的代码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.