FTP Client for Pocket PC
Posted
by Waseem Anis
on November 24th, 2000
Environment: Embedded Visual Tools, NT4 SP5, PocketPC
The class FtpSockClient shows the functionality offered by the pocket PC device for socket data transfer. The class is single threaded, based on the blocking CSocket calls. You can use the class as:
CftpSockClient ftp; // Connect to some server BOOL bResult = ftp.ConnectToServer(_T("ftp.microsoft.com"), 21); if (!bResult) { AfxMessageBox(L"Error Connecting to Server"); return; } // Try logging as anonymous bResult = ftp.UserLogin(L"anonymous", L"dummy@ftpdemo.com"); if (!bResult ) { AfxMessageBox(L"Error Connecting to Server"); return; } CString csDir = ftp.GetWorkingDirectory(); CString csFileList; ftp.GetFileList(csDir, csFileList); ftp. DisconnectFromServer();
The class shows elementary functionality and is an attempt at sockets. Please do tell me the bugs that you find. Ill be glad to fix them...if I am able to.
Downloads
Download source - 7 KbDownload demo project - 52 Kb

Comments
GetFile never returns
Posted by spitla on 07/14/2005 03:26pmHi, I am using your FTPSockClient, it's been working fine upto getting the file. GetFile function keeps on running it never returns. What could be the problem. My device is Symbol MC50 runs on Pocket PC 2003 and is connected to PC via USB connection. Thanks
ReplyFTP Client for Pocket PC
Posted by Legacy on 12/01/2003 12:00amOriginally posted by: Tony
i try to use the method getfile and i get the file empty but with the same size as the source file . please someone tell the sequence of method to use to get a file from ftp server
thanks
ReplyGetFile don't work in Pocket PC 2002
Posted by Legacy on 10/16/2003 12:00amOriginally posted by: Simone Sanfilippo
Hi, I use your code for implementing a ftp class for my application write in embedded Visual C++ 3 for Pocket Pc 2002 (device is Hp Jornada 565).
The GetFile member function do not work, I try it for transfer a text file from my ftp server to my \My Documents folder on pda. But the file in my pda doesn' exist and don't create this file when I call GetFile method.
My code is:
#include "FtpSockClient.h"
#include "Wininet.h"
CFtpSockClient ftp;
int MyApp::SetUpLocale()
{
BOOL bResult;
bResult = ftp.ConnectToServer(_T("192.168.0.105"), 21);
if(!bResult)
{
m_ctrTesto.SetWindowText(_T("Error"));
return 0;
}
bResult = ftp.UserLogin(L"anonymous", L"");
if(!bResult)
{
m_ctrTesto.SetWindowText(_T("Error"));
return 0;
}
bResult = ftp.GetFile(_T("txtfile.txt"), _T("\\My Documents\\txtfile.txt"));
if(!bResult)
{
m_ctrServer.SetWindowText(_T("File don't exist"));
}
else m_ctrServer.SetWindowText(_T("txtfile.txt"));
ftp.DisconnectFromServer();
}
There are errors?
Thanks
ReplySimone
InterConnect() with iPAQ Pocket PC 2002
Posted by Legacy on 06/29/2003 12:00amOriginally posted by: Vikas Jain
I tried to use InterConnect() function in a Pocket PC application, but it gave me an error "This function is only valid in WIn32 mode". Amazingly, InternetOpen seems to be working.
Here is the code:
// prjFTP.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "Wininet.h"
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
HINTERNET hOpenHandle, hConnectHandle, hResourceHandle;
LPVOID lpMsgBuf;
// Open Internet session.
if( (hOpenHandle = InternetOpen(L"Example",
INTERNET_OPEN_TYPE_PRECONFIG,
NULL,
INTERNET_INVALID_PORT_NUMBER,
0) ) == NULL)
{
MessageBox(NULL,L"Open failed",L"Tap OK",MB_OK);
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
0, // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
// Display the string.
MessageBox( NULL, (LPCTSTR)lpMsgBuf, L"Error", MB_OK | MB_ICONINFORMATION );
// Free the buffer.
LocalFree( lpMsgBuf );
}
if( (hConnectHandle = InternetConnect(hOpenHandle,
L"www.yourwebsite.com",
INTERNET_DEFAULT_FTP_PORT,
L"username",
L"password",
INTERNET_SERVICE_FTP,
0,
0)) == NULL)
{
MessageBox(NULL,L"Connect failed",L"Tap OK",MB_OK);
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
0, // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
// Display the string.
MessageBox( NULL, (LPCTSTR)lpMsgBuf, L"Error", MB_OK | MB_ICONINFORMATION );
// Free the buffer.
LocalFree( lpMsgBuf );
}
return 0;
}
I'll appreciate any comments on this.
ReplyFTPGetFile in Pocket PC 2002
Posted by Legacy on 04/29/2003 12:00amOriginally posted by: Nieves
Hello,
I'm building an applicaction in eMbedded Visual C++ and I'm using the Wininet functions for the FTP protocol implementation. When I run the aplication in the Emulator, it runs well, but whe I run the same application in the Pocket PC device I obtain the error 87 ("The parameter is incorrect").
I try with differentd parameters and allways I onbtein the same error.
Does somebody know why?
Thank you,
Nieves
Replyfatal error
Posted by Legacy on 04/26/2003 12:00amOriginally posted by: SRinivas
hi,
Replyi want to use CFtpsockClient in my project,but the problem is my projects settings use precompiled headers and the CFtpsockClient requires not suing pre compiled headers ,how do i solve this.??
regards,
srinivas
why not to include Chinese in the path?
Posted by Legacy on 04/15/2003 12:00amOriginally posted by: xiaoxiao
CString CFtpSockClient::GetResponse( )
{
.....
while( ( csResp.Right(2) != CRLF ) )//CRLF=\r\n
{
int nRead = m_pCtrlSock -> Receive( &ch, 1, 0 );
//if the path include Chinese , it did not response . 汉字在这儿死机
csResp += ch;
}
......
}
If the path is composed by English、number or '_',This Programe is right.But the path including Chinese,eg./中国/
Replyor /中国.txt,this programe haven't response.
Why is it?
this PDA Source convert to Windows Program.
Posted by Legacy on 04/02/2003 12:00amOriginally posted by: ezzi
I wanna convert Windows Programming.
ReplyI'd like to use for Winodws VC++.
Please.
Acronym "afx"
Posted by Legacy on 01/08/2003 12:00amOriginally posted by: Scott Dunham
What does the afx stand for in <afxwin.h>?
Replyembedded Visual Basic??
Posted by Legacy on 09/05/2002 12:00amOriginally posted by: Javier
Is there any ActiveX to develop FTP Clients in embedded Visual Basic???
thanks
ReplyLoading, Please Wait ...