gethostname() returns accurate hostname, bind() doesn't like it
- by user2072848
Doing a python socket tutorial, entire codebase is as follows
import socket as so
s = so.socket()
host = so.gethostname()
port = 12345
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()
and error message:
Traceback (most recent call last):
File "server.py", line 13, in <module>
s.bind((host, port))
File "/Users/solid*name*/anaconda/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
Printing hostname gives me
super*name*
Which is, in fact, my computer's hostname.