I am trying to display all the connected machine names using ip address, I could get the IP address by checking the connection
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((addr,80))
I have tried using s.getsockname
,socket.gethostname
and s.getpeername
these all are returning similiar results
What should I do if I need to display the names? For example
192.168.1.1 - 192.168.1.1
192.168.1.50 - 192.168.1.50
192.168.1.113 - 192.168.1.113
192.168.1.114 - 192.168.1.114
192.168.1.139 - 192.168.1.139
I need to display this like
192.168.1.1 - tom123
192.168.1.50 - allec
192.168.1.113 - john-pc
192.168.1.114 - bob
192.168.1.139 - anny
I have tried with socket.gethostbyaddr("196.168.1.114") -- it is giving me an exception saying
print socket.gethostbyaddr("196.168.1.114")
socket.herror: [Errno 1] Unknown host