Page 1 of 1

FTP

Posted: Sat Jun 27, 2009 6:26 am
by Colin Haig
Hi All

I have an application running on a Samsung Omnia Mobile phone running windows 6 - I am trying to setup FTP
from the phone back to a windows server - using the sample code by Enrico but I cant get hConnect to return a value

hConnect = INTERNETCONNECT( hInternet, "myIP",INTERNET_DEFAULT_FTP_PORT, "myUser", "myPass", INTERNET_SERVICE_FTP,0, 0 )

In a desktop app - I use the tip library to connect back to the same server and have no problems

#include "tip.ch"
function send()
local cServer := '',cUser := '',cPassword := '',oUrl,oFtp,cFile := 'error.log'

cServer := myIP
cUser := myUser
cPassword := myPass
cUrl := "ftp://" + cUser + ":" + cPassword + "@" + cServer

oUrl := tUrl():New(cUrl)
oFtp := tIPClientFtp():New(oUrl,.t.)
oFtp:nConnTimeout := 20000
oFtp:bUsePasv := .t.
oFtp:lTrace := .f.

if oFtp:open(cUrl)
if oFtp:UpLoadFile((cFile))
oFtp:close()
endif
else
?? 'Error openning url'
wait
endif
return(nil)

Thanks for any ideas.

Colin

Re: FTP

Posted: Sat Jun 27, 2009 11:23 am
by Richard Chidiak
Colin

I am not sure tip class is compatible with fwppc, this is a sample of using ftp with fwppc (works with my app since long time)

HTH

Richard

Code: Select all


#define INTERNET_OPEN_TYPE_PRECONFIG                    0   // use registry configuration
#define INTERNET_OPEN_TYPE_DIRECT                       1   // direct to net
#define INTERNET_OPEN_TYPE_PROXY                        3   // via named proxy
#define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY  4   // prevent using java/script/INS

#define INTERNET_INVALID_PORT_NUMBER    0           // use the protocol-specific default

#define INTERNET_DEFAULT_FTP_PORT       21          // default for FTP servers
#define INTERNET_DEFAULT_GOPHER_PORT    70          //    "     " gopher "
#define INTERNET_DEFAULT_HTTP_PORT      80          //    "     " HTTP   "
#define INTERNET_DEFAULT_HTTPS_PORT     443         //    "     " HTTPS  "
#define INTERNET_DEFAULT_SOCKS_PORT     1080        // default for SOCKS firewall servers.

#define INTERNET_SERVICE_FTP     1
#define INTERNET_SERVICE_GOPHER  2
#define INTERNET_SERVICE_HTTP    3

#define INTERNET_FLAG_TRANSFER_ASCII  1
#define INTERNET_FLAG_TRANSFER_BINARY 2

Internet := InternetOpen( "Anystring", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0 ) 
IF hINTERNET = 0
   MSGINFO("ERROR ON CONNEXION")
   RETURN .F.
ENDIF

hCon1 = INTERNETCONNECT( hInternet, MYSITE,INTERNET_INVALID_PORT_NUMBER, MYUSER, MYPASS, INTERNET_SERVICE_FTP, 0,0 )
IF HCON1 = 0
   MSGINFO("ERREUR ON CONNEXION FTP  ")
   RETURN .F.
ENDIF

// RETREIVE THE FILES HERE

INTERNETCLOSEHANDLE( hCon1 )
INTERNETCLOSEHANDLE( hInternet )

 

Re: FTP

Posted: Sat Jun 27, 2009 2:04 pm
by Colin Haig
Hi Richard

Thanks for your sample code - I still cant get the HCON1 to work - I get a
hInternet value - is there any other settings on the phone I should look at ,
I have the browser set to WAP and have tested I can get a website on the phone.

Regards

Colin

Re: FTP

Posted: Mon Jun 29, 2009 4:59 am
by Richard Chidiak
Colin

Check the website spelling, www...... better thant ftp...... , userid and password and the location directory, if you are connecting to a linux server "/" for directory etc...

HTH

Richard

Re: FTP

Posted: Mon Jun 29, 2009 5:58 am
by Antonio Linares
Colin,

Are you able to access the web from your emulator or your phone ?

have you tried to access ftp.microsoft.com for reading ?