简体   繁体   English

是否可以在两个android设备之间直接将数据传输到同一网络中的其他用户?

[英]Is it possible to transfer data directly between two android devices to other users in the same network?

Let's say I have two android mobile devices, connected to the same wireless network, and that network hasnt external/internet access. 假设我有两个连接到同一无线网络的android移动设备,并且该网络没有外部/互联网访问权限。

Without third party software, is it possible to transfer data through wifi without knowing the ip from each other and without creating an hotspot? 如果没有第三方软件,是否有可能通过wifi传输数据而彼此之间不知道ip且不创建热点? Something like we do on Windows (if 2 pcs are on same network, they can share information directly without internet access) 就像我们在Windows上所做的一样(如果2台电脑位于同一网络上,它们可以直接共享信息而无需访问互联网)

Starting with the basics, I would like to develop an application, where android phones on same network appears on a list , and then a user choose on of them and writes something - and if the other user have the same app running, appears that on his phone (and then he can reply of course - basically, a chat. 从基础开始,我想开发一个应用程序,在该应用程序中,同一网络上的android手机出现在列表中,然后用户选择它们并编写一些内容-如果其他用户正在运行相同的应用程序,则显示他的电话(然后他当然可以回复-基本上是聊天。

I know this make no practical sense, but believe makes all the sense for what I need to do (it's not a chat of course). 我知道这没有实际意义,但是相信对于我需要做的事情来说是有道理的(当然,这不是聊天)。 If anyone knows anything, please help me - i found nothing. 如果有人知道什么,请帮助我-我什么也没找到。

Thanks in advance. 提前致谢。

If you want to send data or messages from one phone to another using the network you will eventually need the IP address of the recipient phone. 如果要使用网络将数据或消息从一部电话发送到另一部电话,则最终将需要接收方电话的IP地址。 However, If you don't care about targeting specific phones you could always send UDP broadcast packets that each device on the network should receive. 但是,如果您不关心定位特定的电话,则可以始终发送网络上每个设备应接收的UDP广播数据包。

If you don't want to manually specify an IP you'll need to create a discovery protocol that a phone uses to discover all the other phones on the network. 如果您不想手动指定IP,则需要创建一个发现协议,电话可以用来发现网络上的所有其他电话。 You could do this buy scanning all available IP addresses and checking to see if they are a valid android phone. 您可以这样做来扫描所有可用的IP地址,并检查它们是否是有效的Android手机。 Or you could have each phone broadcast its presence on the network using a UDP broadcast packet sent to a predefined port. 或者,您可以使每个电话使用发送到预定义端口的UDP广播数据包在网络上广播其状态。

Once you have discovered all the phones on the network its really up to you to decide how you want to send the data between phones and there are hundreds of examples of how to send data between devices/computers/processes using sockets. 一旦发现了网络上的所有电话,就由您决定要如何在电话之间发送数据,并且有数百个示例说明了如何使用套接字在设备/计算机/进程之间发送数据。

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

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