简体   繁体   English

在局域网中查找服务器

[英]Finding server in LAN

How to find, in python, server without having it's IP in LAN? 如何在python中找到服务器而不在LAN中拥有IP?
I assume that port will be configured in file so its doesn't have to find port. 我假设端口将在文件中配置,因此它不必查找端口。
I tried to search on google but I couldn't find anything useful or that could help me with it. 我尝试在Google上进行搜索,但找不到任何有用的信息或可以帮上忙的东西。
The server IP will be changing because it will not run constantly on the same computer. 服务器IP将更改,因为它不会在同一台计算机上持续运行。
So basically I got app with server that is on random computer in network, and I want to find its IP from another computer. 因此,基本上我得到的应用程序与服务器位于网络中的随机计算机上,我想从另一台计算机上查找其IP。
I would be really thankful for either explanation how to do it or link that could help me to do it. 我真的很感谢您对如何执行此操作的说明或可以帮助我执行此操作的链接。

Not certain if this is what you want to do, I think you want to find the IP of a server by running some python execution on the server? 不确定这是否是您要执行的操作,我想您想通过在服务器上运行一些python执行来查找服务器的IP?

You could try : 您可以尝试:

from subprocess import call
  call (["ipconfig"])

This will dump the IP config and you can parse out the IP address. 这将转储IP配置,您可以解析IP地址。 This assumes a windows server. 假设使用Windows服务器。 You would have to modify the call for your OS. 您将必须修改操作系统的调用。


Updated : 更新 :

Check this out : TCP Communications or UDP Communications ... it looks like what you are looking for. 检查一下: TCP通信UDP通信 ...看起来像您要找的东西。 You will still have the mess of determining the available addresses on the network (arp -a), and testing each one - this would be your client side app. 您仍然会费心地确定网络上的可用地址(arp -a),并测试每个可用地址-这将是您的客户端应用程序。 Your server side app, when it receives the right query on the TCP or UDP port, would then determine it's address (ipconfig) and return the value. 您的服务器端应用程序在TCP或UDP端口上接收到正确的查询时,将确定其地址(ipconfig)并返回该值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM