1

I'm writing a very simple demo for python sockets, with a server and client.

Server side code:

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()

Client side code:

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 ()

However, I get this error:

[Errno 8] nodename nor servname provided, or not known

whenever I try to run either code. What does it mean and how can I fix it?

0 Answers0