简体   繁体   English

在不扫描整个网络的情况下发现本地网络中的服务器

[英]Discovering a server in a local network without scanning the entire network

I am writing a program in Java that involves one computer creating a server and another one that finds the server's IP and creates a connection to it. 我正在用Java编写一个程序,其中涉及一台计算机创建服务器,另一台计算机查找服务器的IP并创建与服务器的连接。

The method i am looking for is similar to that of the SHAREit app. 我正在寻找的方法类似于SHAREit应用程序。 I tried to search through out the subnet in my network, 192.168. 我试图搜索网络中的子网192.168。 . , for a computer with a particular open port but it took a long time, so I'm looking for a better way. ,对于具有特定开放端口的计算机,但是花费了很长时间,因此我正在寻找更好的方法。

The solution is to broadcast a message from the server, once the client receives it it will contact the server. 解决方案是从服务器广播消息,一旦客户端收到消息,它将与服务器联系。

example in java Java中的示例

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

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