Android Tutorial [B4X] Net library (FTP, SMTP, POP) with Wait For

Discussion in 'Tutorials & Examples' started by Erel, Oct 9, 2017.

  1. Erel

    Erel Administrator Staff Member Licensed User

    Starting from v1.70 of Net, jNet and iNet libraries the asynchronous methods return a 'sender filter' object.
    This object can be passed as the sender filter parameter in a Wait For call.
    This makes it simpler to manage multiple requests.

    For example:
    Code:
    'ftp was previously initialized and its event name was set to ftp:
    'ftp.Initialize("ftp", "your.server", 21, "user", "password")
    Dim sf As Object = ftp.UploadFile(File.DirAssets, "somefile"False"/somefile")
    Wait For (sf) ftp_UploadCompleted (ServerPath As String, Success As Boolean)
    If Success Then
       
    Log("file was uploaded successfully")
    Else
       
    Log("Error uploading file")
    End If
    Multiple subs can wait for the same event. Thanks to the sender filter parameter, each event will be intercepted in the correct wait for call.

    The same technique can be used with all asynchronous methods in the Net library.

    Notes

    - iNet v1.70 will be included in B4i v4.40.
     
    Beja, BillMeyer, freedom2000 and 3 others like this.
  2. Beja

    Beja Expert Licensed User

    This is a great function.. thanks Erel.. I remembered ProComm for DOS with Kermit protocol.. from the old good days.
     
  3. AHilton

    AHilton Active Member Licensed User


    Completely off topic but, I worked on ProComm Plus for Datastorm back in the late 80's - 91.
     
    Last edited: Oct 12, 2017
  4. Beja

    Beja Expert Licensed User

    May be off topic but definitely not completely.. If you understood I meant in early nighties there was an Android function called Wait For then what can I say.
    The word WaitFor rang and reminded me a similar word. and invoked memories

    WaitFor "User ID"
    Transmit "my ID"
    WaitFor "Password"
    Trasmit "xdsoh68"
    WaitFor "File Name"
    .
    .
    And so on.

    I was writing this script to automate the file transmission process instead of responding to prompts one by one.
    Modem: Hayes
    Media: Phone line.
     
    Last edited: Oct 12, 2017
Loading...