Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding Live Nodes on LAN using Python

I am creating a Messenger which is same as IP Messenger in Python 2.7 and Windows.

I want the same functionality as IP Messenger uses in finding the systems running same software over LAN but I am unable to understand the technique.

Can someone please help me to solve the problem of Finding the computers IP address or host name running same software over the LAN using Python 2.7 and Sockets Library.

Please suggest something which can be implemented on Windows not like Nmap(limited to linux) and it will be very helpful if solution is Python's Socket Library code.

like image 289
aki92 Avatar asked Mar 17 '13 18:03

aki92


1 Answers

" net view " command of Windows command prompt solved my problem stated in question.

By this command I am able to find all the computers connected to my computer through LAN and then I will send packets to all computers and computers replying to my packet would be the systems running same software as I am running which completely solved my problem.

This code lists out all the computers host names connected with my computer over LAN.

import os
os.system('net view > conn.tmp')
f = open('conn.tmp', 'r')
f.readline();f.readline();f.readline()

conn = []
host = f.readline()
while host[0] == '\\':
    conn.append(host[2:host.find(' ')])
    host = f.readline()

print conn
f.close()    
like image 102
aki92 Avatar answered Sep 20 '22 15:09

aki92