使用Python在LAN上查找实时节点 [英] Finding Live Nodes on LAN using Python

查看:143
本文介绍了使用Python在LAN上查找实时节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个与Python 2.7和Windows中的IP Messenger相同的Messenger。

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

我想要与IP Messenger在中找到相同的功能通过局域网运行相同软件的系统,但我无法理解该技术。

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.

有人可以帮我解决问题 使用Python 2.7和套接字库查找通过LAN运行相同软件的计算机IP地址或主机名

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.

请提出可以建议的内容在Windows上实现的不像Nmap(限于linux),如果解决方案是Python的套接字库代码,它将非常有用。

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.

推荐答案

Windows命令提示符的 net view 命令解决了我所述的问题。

" 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.

此代码列出了与我的计算机连接的所有计算机主机名LAN。

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

这篇关于使用Python在LAN上查找实时节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆