如何在局域网中找到我的服务器? [英] How to find my server in LAN?

查看:168
本文介绍了如何在局域网中找到我的服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C ++和Java上有两个自己的应用程序:服务器和客户端。它在一个局域网中,可以通过指定端口传输数据。我想让它成为可能,客户端可以找到服务器的IP。但是怎么样?
使用地址掩码枚举所有可能的IP - 不好的想法,这将花费很多时间。可能存在某种方式,我可以从客户端向LAN发送广播并在服务器中接收它?或者另一种方式......我无法找到有关此信息,但我认为这是可能的,因为我在Android上的MyPhoneExplorer中看到它,例如。

I have two my own applications on C++ and Java: server and client. It both in one LAN and can transfer data via specified port. I want to make it possible, that client can find IP of server. But how to? Enumeration of all possible IP with address mask - bad idea, it will take a lot of time. May be exists some way, where I can send broadcast to lan from client and receive it in server? Or another way... I can't find information about this, but I think that is possible, because I see it in MyPhoneExplorer on android, for example.

推荐答案

为什么不使用UDP广播?
客户端可以UDP广播我在x.x.x.x,服务器可以回答(在UDP中)客户端,我在y.y.y.y。

Why not using UDP broadcast? the client can UDP broadcast "I am at x.x.x.x", and the server can answer (in UDP) to the client, "I am at y.y.y.y".

这篇关于如何在局域网中找到我的服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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