我正在为一个服务器和客户端编写一个非常简单的python套接字演示。
服务器端代码:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = socket.gethostname()
port = 8888
s.bind((host, port))
s.listen(5)
while True:
c, addr = s.accept()
print 'Got connection from', addr
c.send('Thank you for connecting')
c.close()
客户端代码:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = socket.gethostname()
port = 8888
s.connect((host, port))
print s.recv(1024)
s.close ()
然而,我收到此错误:
[Errno 8] nodename nor servname provided, or not known
每当我尝试运行任一代码时。它是什么意思,我该如何解决?