Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Using rapi from desktop to copy file from device to desktop

Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 10-22-2010, 08:03 PM
Senior Member
 
Join Date: Oct 2010
Posts: 128
Default

Sorry to dig up this old thread but this is relevent to a part of the project I'm working on.

I'm trying to synchronize a database between the PC and device. I know I can use RAPI on the desktop - which wouldn't be a problem, except it seems to lockup to application while the transfer is occurring.

Using the network library solved this problem and I was able to get a status of the file being sent per the 'FileTransfer' example - however, I can only seem to get the network library to be able to send files to the PC from the device and not the other way around.

Is there something I can do with RAPI Library to make it not lock the application or something I can do with the Network Library to make the transfer bi-directional?

Thanks!
Reply With Quote
  #12 (permalink)  
Old 10-23-2010, 08:38 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by Tex8503 View Post
Is there something I can do with RAPI Library to make it not lock the application
You could try running the transfer on a thread using my Threading library. If you are not familiar with threading read the help carefully to avoid coding in problems for yourself.

Quote:
or something I can do with the Network Library to make the transfer bi-directional?
There shouldn't be any problem as you have a two-way communucation channel between the client and server. You just need to write the code for both the server and client to implement this.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #13 (permalink)  
Old 10-23-2010, 12:44 PM
Senior Member
 
Join Date: Oct 2010
Posts: 128
Default

Agrham - Very interesting. I know OF threading, so I'd be interested in trying that with the RAPI - but it'd be easier for me if I can figure out how to get the damn networking library to work because it's already implemented and serves more of what I'm trying to do.

I basically broke apart the file transfer app into two separate applications and the PC acts as the server and the win mo device is the client. The FileTransfer example was pretty straight forward of how the client can initiate a file transfer to the server - but I still don't understand how the server could send a file back.

I thought of the possibility of re-arranging it so when I needed to send the file back to the win mo device, that I made the win mo device the server and the PC the client and just doing it that way. This has yet to work for me and I wondering its because the it can't get the hostname for the device using PPP_PEER - or if it has something to do with the win mo device / cradle not having USB Host.

Any suggestions? Am I even going in the right direction?
Reply With Quote
  #14 (permalink)  
Old 10-23-2010, 01:15 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

I don't understand your problem with the Network library. The server can send a file back in the same way the client sent one to the server. Once you have a client and a server connected you just write the code to do whatever you want.

PPP_PEER is only applicable to identify the desktop host of an ActiveSync connection.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #15 (permalink)  
Old 10-25-2010, 08:43 PM
Senior Member
 
Join Date: Oct 2010
Posts: 128
Default

agraham - Can the server send data back in the same way? I haven't seen anything to suggest that...

It seems like the steps that happen are :
1)Server waits for client connection
2)Client connects using 'connect' and establishes bitstream
3)Server sees data is available.
4)client supplies opening bit, file size and file name then file
5)server receives in that order
6)Server reconciliation occurs (happens outside network library)
7)?

That's where I'm stuck. Can the server just write to the bitstream and have the client receive?
Reply With Quote
  #16 (permalink)  
Old 10-25-2010, 10:55 PM
Basic4ppc Veteran
 
Join Date: May 2008
Location: Newcastle Upon Tyne - England
Posts: 271
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by Tex8503 View Post
Can the server send data back in the same way?
Yes. Because on the Server side; a Client and BinaryFile stream are also set up. Add these snippets to your SERVER code. You will need two timers too, one WFC(Wait For Connection) and one WFD(Wait For Data):

'Server' is a Network.dll Server object
'Client' is a Network.dll Client object
'Stream' is a BinaryFile.dll BinaryFile object

Code:
Sub App_Start
    
'...
    Server.New1(50000)
    Server.Start
    Client.New1
    TimerWFC.Enabled=
True
    
'...
End Sub

Sub TimerWFC_Tick
    
If Server.Pending=True Then
        Client.Value=Server.Accept
        Stream.New1(Client.GetStream,
False)
        TimerWFC.Enabled=
False
        TimerWFD.Enabled=
True
    
End If        
End Sub

Sub TimerWFD_Tick
    
If Client.DataAvailable=True Then
        Variable=Stream.ReadString
    
End If
End Sub
To write anything back; use any of the BinaryFile.Writexxxx methods, such as

Code:
...
Stream.WriteString(
"ASCII Text")
...
Reply With Quote
  #17 (permalink)  
Old 10-26-2010, 02:35 PM
Senior Member
 
Join Date: Oct 2010
Posts: 128
Default

Thanks Zenerdiode & agraham - took me about an hour to work through the issues I was having with the bi-directional transfer and while it's not pretty at the moment, it is working, which is more than I could say for it as of yesterday!

Thanks again for your help. If someone needs/wants it - I probably can rip the the code out of my app and setup something to demonstrate the bi-directional transfer.
Reply With Quote
  #18 (permalink)  
Old 10-26-2010, 06:28 PM
Senior Member
 
Join Date: Oct 2010
Posts: 128
Default

One last quick question: is it possible for multiple clients to connect to one server at the same time?
Reply With Quote
  #19 (permalink)  
Old 10-26-2010, 07:48 PM
derez's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Posts: 978
Awards Showcase
Beta Tester Competition Winner 
Total Awards: 2
Default

Yes, using timestamp as addition to the connection to diferentiate the clients, see my chat application which uses this technic, provided by Erel sometime in the past.

http://www.basic4ppc.com/forum/share...html#post19297
__________________
David Erez
Ramat Hasharon, Israel
Reply With Quote
  #20 (permalink)  
Old 10-27-2010, 01:08 PM
Senior Member
 
Join Date: Oct 2010
Posts: 128
Default

Hey David,
Thanks for the tip. I'll take a look at your code and hopefully I can build it in!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Device or Desktop DaveW Questions (Windows Mobile) 2 11-07-2008 12:04 PM
FileSize(file) brings up error on device - but not on Desktop TWELVE Questions (Windows Mobile) 7 05-10-2008 02:54 PM
Using RAPI library to transfer database from device to desktop mozaharul Questions (Windows Mobile) 4 04-01-2008 08:55 AM
Different behaviour DeskTop and Device HARRY Questions (Windows Mobile) 2 02-22-2008 12:36 PM
Problems using rapi to send files to desktop sunnyboyj Questions (Windows Mobile) 4 01-06-2008 05:40 AM


All times are GMT. The time now is 06:29 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0