需要在Android中获得IP地址的客户端服务器,有没有更好的办法? [英] need to get IP address for client server in Android, Is there a better way?

查看:177
本文介绍了需要在Android中获得IP地址的客户端服务器,有没有更好的办法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用插座两个Android平板电脑连接与使用同一路由器通过WiFi网络。一个是服务器而另一个是客户。

I used sockets to connect two Android tablets as a network over wifi using the same router. one is a server and the other is a client.

问题是,我要连接的客户端和服务器片每一次,我都在服务器平板电脑的IP地址在客户端平板电脑打字。有没有办法避免这种情况?

the problems is that every time I want to connect the client and server tablets, I have to type in the server tablet's IP address in the client tablet. Is there a way to avoid this?

我还没有想出如何在服务器IP地址发送给客户端平板电脑,他们都联网了。

I have not figured out how to send the server IP address to the client tablet before they are networked.

我希望有网络的两片,而不必知道服务器平板电脑的IP地址的方式。

I wish there was a way to network the two tablets without having to know the IP address of the server tablet.

一个想法是让服务器平板电脑连接到PHP编写的网站,有网站获取IP地址,并将其存储在数据库中。接下来,我将有客户端的平板电脑从网站获得的IP地址。然后让服务器的IP客户端平板电脑将abble进行连接。这一切都将避免用户无需知道IP和他们想连接每次键入它。

One idea is to have the server tablet connect to a website written in php and have the website get the IP address and store it in a database. next i would have the client tablet get the IP address from that website. Then the client tablet having the server's IP will be abble to make the connection. All of this will avoid the user having to know the IP and typing it in every time they want to connect.

我相信其他人做过这样的事情,并解决了这个问题。任何想法?

I am sure that others have done something like this before and solved this problem. Any ideas?

推荐答案

我有这样的Andr​​oid应用。我所做的是通过使用多播网络。看一个例子这里

I had this kind of android app. What I did is by using a Multicasting network. See an example here

由于组播网络使用一组IP,这里是我建议的想法

Since Multicast Network uses a group IP, here's my suggested idea


  • 服务器平板电脑将充当接收器

  • 客户端将是一个发送者(他们将自己的本地IP发送到接收器)

这篇关于需要在Android中获得IP地址的客户端服务器,有没有更好的办法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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