Android Tutorial .Net FileTransfer - Implement AsyncStreams Prefix mode

Discussion in 'Tutorials & Examples' started by Erel, Jul 4, 2013.

  1. Erel

    Erel Administrator Staff Member Licensed User

    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:

    [​IMG]

    [​IMG]

    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.
     

    Attached Files:

    metheoneandonly likes this.
  2. Gnappos

    Gnappos Member Licensed 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
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    The purpose of this code is to demonstrate how to implement the "AsyncStream prefix streaming" mode in .Net. It shouldn't be difficult to include this code in any type of .Net application.
     
  4. tuhatinhvn

    tuhatinhvn Active Member Licensed User

    Can i make application in VB 6.0??

    Thank
     
    ComposerB4A likes this.
  5. Erel

    Erel Administrator Staff Member Licensed User

    Please do not post duplicate questions.
     
  6. ComposerB4A

    ComposerB4A Member Licensed User

    Hi, one question please, ¿this example works for Wifi and/or "Internet Móvil"? ¿The IP in "Internet Móvil" is Variable/Changing?
     
  7. carbonsystem

    carbonsystem New Member Licensed User

    Hi Erel,
    Where is the link to the example in vb4android?
    How to send a large file?
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    This example will work with any valid connection. You cannot connect two devices over the internet.

    Basic4android example: l FileTransfer - Send and receive files with AsyncStreams
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    You should start a new project and add Form1 code. Or just open it with a text editor and copy the relevant code.
     
  10. pauleffect

    pauleffect Member Licensed 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: Jan 27, 2014
    onder and Erel like this.
  11. Erel

    Erel Administrator Staff Member Licensed User

    Test it with the executable included in the demo. If it works properly then the problem is in your implementation.
     
  12. Yafuhenk

    Yafuhenk Active Member Licensed 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
     

    Attached Files:

  13. Erel

    Erel Administrator Staff Member Licensed User

    What happens on the Android side? Are there any error messages?
     
  14. Yafuhenk

    Yafuhenk Active Member Licensed 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.

    Code:
    ** 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 **
     
  15. Erel

    Erel Administrator Staff Member Licensed User

  16. Yafuhenk

    Yafuhenk Active Member Licensed User

  17. Yafuhenk

    Yafuhenk Active Member Licensed 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
     
  18. Erel

    Erel Administrator Staff Member Licensed User

    Have you seen the message about the endianess at the end of the first post?
     
  19. Yafuhenk

    Yafuhenk Active Member Licensed 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.

    Code:
    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).
     

    Attached Files:

  20. code4fun

    code4fun Member Licensed User

    Could the server code be in python running on a linux machine? Has anyone tried converting the code to the python equivalent?
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice