Android Tutorial .Net FileTransfer - Implement AsyncStreams Prefix mode

The attached C# project, implements the new stream protocol of AsyncStreams.
Relevant tutorials:
AsyncStreams Tutorial
FileTransfer - Send and receive files with AsyncStreams

This project allows you to connect the desktop to the FileTransfer app:

SS-2013-07-04_10.34.17.png


SS-2013-06-24_13.24.55.png


Note that the desktop doesn't open a server. So it can only connect to the device.

The SharpZipLib library, which is included in the zip file, is required for the checksum calculation.

There is a single change that needs to be done in device FileTransfer app:
AsyncStreams should use little endian instead of big endian. This is done by setting the second parameter of astream.InitializePrefix to False (Sub StartAStream).

The C# source code and executable are attached.
 

Attachments

  • FileTransfer-Desktop.zip
    81.2 KB · Views: 4,651

Gnappo jr

Active Member
Licensed User
Longtime User
FileTransfer the Desktop app: It is very interesting, you might have an update so that it functions also as a SERVER? I think this is very useful for many people.
thanks
 

ComposerB4A

Member
Licensed User
Longtime User
Hi, one question please, ¿this example works for Wifi and/or "Internet Móvil"? ¿The IP in "Internet Móvil" is Variable/Changing?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User

pauleffect

Member
Licensed User
Longtime User
For anyone interested:
File -> New -> Project from existing code, select the folder where you saved these files, done.

If you dont have project from existing code (as was in my case) read this.
PS: don't forget to PROJECT -> Add reference : browse for ICsharp(...).zip.dll

@Erel Thank you! If you ever find yourself in Romania, beers on me!
I apologize for not thinking about it. I mean... it's lame. I've deleted my pointless post here! keep this one though!
 
Last edited:

Yafuhenk

Active Member
Licensed User
Longtime User
Hi thanks for the .NET code. My goal is to send sqlite database to my Android device.
However I am facing a problem. A soon as I send a file, my Android device disconnects.
Could it be that this program only works with the latest B4A version?
This is what I am using
B4A version 3.0
B4A Library versions: Network 1.25, RandomAccessFile 2.00
B4A Demo program File Transfer
PC the attached FileTransfer.exe
Thanks for any suggestion

Henk
 

Attachments

  • 2015-02-04 10_34_29-FileTransfer-Desktop.jpg
    2015-02-04 10_34_29-FileTransfer-Desktop.jpg
    36.2 KB · Views: 977

Yafuhenk

Active Member
Licensed User
Longtime User
Hi Erel,

Thanks for your reply.
Yes there is an error message on the Android side.
Error: (RuntimeException) java.lang.RuntimeException: Message size too large. Prefix mode can only work if both sides of the connection follow the 'prefix' protocol.
See also the log file below.

B4X:
** Activity (main) Resume **
StartAStream
Error: (RuntimeException) java.lang.RuntimeException: Message size too large. Prefix mode can only work if both sides of the connection follow the 'prefix' protocol.
** Activity (main) Pause, UserClosed = false **
 

Yafuhenk

Active Member
Licensed User
Longtime User
Hi Erel. I did not change the pc app in anyway. There is an exe file attached which I used.

The example you are referring too I already tested and it works fine. The desktop app is however is written in B4J when I remember correctly. I have to implement the feature in a vb.net application. That is the reason that i was so happy finding this c# .net version. Coverting it to vb.net was easy. But as i said i didn't test this vb.net version i tested the already existing and to the forum attached exe file
 

Yafuhenk

Active Member
Licensed User
Longtime User
Hi Erel,

That did it! Thanks!


For anyone who is interested in the vb.net FileTransfer solution here it is.
Regarding the Android side don't make the same mistake as I did.
As Erel pointed out: read the first post.

B4X:
There is a single change that needs to be done in device FileTransfer app:
AsyncStreams should use little endian instead of big endian. This is done by setting the second parameter of astream.InitializePrefix to False (Sub StartAStream).
 

Attachments

  • vbFileTransfer.zip
    172.5 KB · Views: 1,447

code4fun

Member
Licensed User
Longtime User
Could the server code be in python running on a linux machine? Has anyone tried converting the code to the python equivalent?
 
Top