Python Forum
Display name of a pc connected over lan
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display name of a pc connected over lan
#1
Hi guys.
On my lan i have the following pc (ip -> pc name):
Quote:192.168.0.1 → pc01
192.168.0.114 → pc02
192.168.0.118 → pc03
192.168.0.136 → pc04
My code is:
ip_list = [‘192.168.0.114’, ‘192.168.0.118’, ‘192.168.0.1’, ‘192.168.0.136’]
for ip in ip_list:
print(ip)
for ip in ip_list:
print(socket.gethostbyaddr(ip))
Output of first loop for is:
Quote:192.168.0.114
192.168.0.118
192.168.0.1
192.168.0.136
and the output of second loop for is::
Error:
print(socket.gethostbyaddr(ip)) socket.herror: [Errno 1] Unknown host
Libraries are imported correctly.
I’d like an output like this:
Quote:pc02
pc03
pc01
pc04
What am i wrong??
Reply
#2
Suggestion: find how to get the names of the connected hosts without Python. Once you can do that, Python can do it for you.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [mysql.connector] The database is never connected to and there are no errors SheeppOSU 7 4,117 Jun-04-2020, 09:47 PM
Last Post: SheeppOSU

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020