简体   繁体   English

如何在Android平台上利用网络进行p2p文件共享?

[英]How to utilize network for p2p file sharing on Android Platform?

I'm working on some apps for the android platform and I have two problems that I'm not quite sure how to approach, and both are closely related. 我正在研究Android平台的一些应用程序,我有两个问题,我不太确定如何处理,两者密切相关。

  1. How can I send a relatively small data file from one android device to another (preferably over the internet or directly through wireless network)? 如何将一个相对较小的数据文件从一个Android设备发送到另一个(最好通过互联网或直接通过无线网络)?

  2. Is it possible to create a temporary p2p live data stream from one android device to another? 是否有可能从一个Android设备创建一个临时的p2p实时数据流到另一个? An example application would be to stream low-res video from phone A's camera to phone B, or audio. 一个示例应用是将低分辨率视频从电话A的摄像机传输到电话B或音频。

I would much appreciate being pointed in the right direction on either issue (File transfer or real time data transfer). 我非常感谢在任何一个问题上指向正确的方向(文件传输或实时数据传输)。

You could try to get Google's library libjingle to work on Android. 您可以尝试让Google的库libjingle在Android上运行。 It provides quite advanced NAT Traversal capabilities, which should be able to get through the carriers' firewalls. 它提供了非常先进的NAT Traversal功能,应该能够通过运营商的防火墙。

一种方法是在java.net中使用套接字类。

To use WiFi to send data among devices, you can try to establish an ad-hoc network among the devices that will communicate. 要使用WiFi在设备之间发送数据,您可以尝试在要通信的设备之间建立ad-hoc网络。 I think you can use Android's WiFi API to do that. 我认为你可以使用Android的WiFi API来做到这一点。 Once you have the ad-hoc network setup, you can establish a simple TCP connection between the devices and transfer the files. 一旦进行了ad-hoc网络设置,就可以在设备之间建立简单的TCP连接并传输文件。

Sockets do not work between phones. 套接字在手机之间不起作用。 I've tried with two actual phones using socket communications and there seems to be a firewall in the carriers that prevents communications on ports different than port 80. Then if you try to use port 80 you get a 'Permission Denied' exception. 我尝试使用套接字通信的两个实际手机,并且运营商中似乎有防火墙阻止端口80上的端口通信。然后,如果您尝试使用端口80,则会获得“权限被拒绝”异常。

One possibility is to investigate the JXTA framework. 一种可能性是调查JXTA框架。 The Practical JXTA II book is available online for reading at Scribd. 实用的JXTA II书籍可在线阅读,可在Scribd阅读。

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

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