- TCP - start the server first, ServerSocket.accept() blocks
- UDP - start the client first, DatagramSocket.receive() blocks
The meat of the server/client code comes from Real's How To site.
-
Let the 2 phones connect to the same network.
I turned on my ad-hoc barnacle with the same name on both phones
-
Figure out the IP address of the server. Put it under the
TODO server's IP address
in src/.../aaFileSTransfer.javaYou can go into
./adb shell
andnetcfg
to see the IP If you need to change the IP, in the shell do:ifconfig eth0 192.the.new.ip
-
Put in the file source location in the server under
TODO: put the source of the file
-
Put in the destination path in the client under
TODO: Put where you want to save the file
-
Install this "aaFile_Transfer" app on both phones
-
On the Server phone, press "Start Server to Wait for Transmit". The button sometimes turn orange and stay that way because it's waiting for connections. Even if the button doesn't turn orange (I know, it's terrible UI), it's probably also working, so you can go on ...
-
On the Client phone, press "Start Client Receive".
-
On the Client phone, view if the file transfer was successful, navigate to your specified destination path using:
./adb shell
- the app: File Manager
- The third option is to view the contents of /mnt/sdcard as a USB storage. To do so:
- swipe down on the home view
- select
USB connected
- click
Turn off USB storage
- Now you can view /mnt/sdcard/* as a connected USB drive
-
If you downloaded to '/mnt/sdcard/download', your download might not show up in 'Downloads'
-
You might not have '/mnt/sdcard/download' directory if you have never downloaded anything on your iPhone
-
To view You might have to try disable/enable the "USB Connected" option on the phone to be able to view in
- Better UI for the server button to let users know when the server is waiting for connections
- Make a button to let server stop waiting to transfer
- Let the user know the status of the transfer (success/fail)
Just a simple UDP transmission with the meat of the code coming from helloandroid.
-
Let the 2 phones connect to the same network.
I turned on my ad-hoc barnacle with the same name on both phones
-
Fill out the
TODO: fill in UDP Client IP
-
Click on the "Start UDP Client" button
-
Click on "Start UDP Server" button
-
Observe in logcat:
D/Udp tutorial( 1167): message:Hello Android!