简体   繁体   中英

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.

  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)?

  2. Is it possible to create a temporary p2p live data stream from one android device to another? An example application would be to stream low-res video from phone A's camera to phone B, or audio.

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. It provides quite advanced NAT Traversal capabilities, which should be able to get through the carriers' firewalls.

一种方法是在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. I think you can use Android's WiFi API to do that. Once you have the ad-hoc network setup, you can establish a simple TCP connection between the devices and transfer the files.

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.

One possibility is to investigate the JXTA framework. The Practical JXTA II book is available online for reading at Scribd.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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