|
Yes I can.
That's mainly why I can't figure out the reason for a simple console application failing to link. It's almost a "hello world" console application. I include FTPClient.h in the main module, and at linkage, I get the error I posted earlier. I've figured out the symbols reported missing by the compiler belong to winsock2.h, which rules out errors in the source code.
I'm guessing it has something to do with build directives ...
Any light?
Thanks
|
|
|
|
|
Thanks Lushan111,
I got it. The problem was related to the fact that the FTPClient code uses window.h and winsock2.h ... Windows.h uses winsock.h, and some symbols get mixed up because of that. You might say that if you include winsock2.h before windows.h, there wouldn't be a problem.
Since this isn't always possible, add the lib (Ws2_32.lib) to the linker settings.
Out
|
|
|
|
|
I'm using the class for a uploading job, but I met a problem there and I'm looking for your help.
I built a ActiveX component and 2 threads in the ActiveX. One is used for UI and the other is used for uploading. I called the functions in the following sequence:
ftpClient.Login( ... );
ftpClient.Upload( ... );
During the uploading, I disable the network connection. Then the function uploading returns a "false" to me.
Then after 3 minutes, I enable the network connection and call ftpClient.Login, ftpClient.Upload again for resuming the job. I expect all the functions calls behave like the first time, but I'm wrong.
I found an internal error there when I called the function Upload, after several seconds as the timed-out number.
Internal Error: Receive timeout error :\generalv\gvclient\generalv\ftpclient_demo\ftpclient.cpp:1,102 files..
I need to wait for a very long time, and restart the process, it seems work again.
Anyone knows why? Please help me....
Thanks,
|
|
|
|
|
Is it a new ftpClient instance when you call Login the second time or is it the instance which you used on the first try?
If it is the same instance then try to use a new one. Will this error only occurr in conjunction with the ActiveX control? What compiler do you use? What service pack (if you use visual studio) have you installed? Have you tried this scenario with different ftp servers? Have you tried to use an other ftp client for the second call?
|
|
|
|
|
I tried using both the same instance and a new one to do so. All seems not working if they are in the same process.
During the upload call, I disable the network connection, and after several miniutes after the function returned, I call Login and Upload again, and the login succeeded but upload fail.
If I close the application and reopen it. It works again.
I think i need to call some method of the ftpclient to clear the environment, such as close all the sockets, to make it like a fresh one, but I can't found a method to do so.
Do you recommend me to add a method to do so?
I'm using VS 2005 on Windows XP SP2.
-- modified at 4:46 Friday 15th June, 2007
|
|
|
|
|
Following is my code, it is really simple. Please correct me if I have something wrong.
void CFTPClient1Dlg::OnBnClickedButton1()
{
nsFTP::CFTPClient ftpClient(nsSocket::CreateDefaultBlockingSocketInstance(), 30);
nsFTP::CLogonInfo loginInfo;
loginInfo.SetHost(static_cast<lpctstr>(_T("192.168.1.10")), static_cast<ushort>(2211),
static_cast<lpctstr>(_T("user")), static_cast<lpctstr>(_T("passwd")),
static_cast<lpctstr>(_T("")));
bool hr = false;
hr = ftpClient.Login( loginInfo );
if ( hr )
{
MessageBox( L"Login Succeeded" );
}
else
{
MessageBox( L"Login Failed" );
return;
}
hr = ftpClient.UploadFile( _T("d:/video7.flv"), _T("1.flv") );
if ( hr )
{
MessageBox( L"Upload file succeeded" );
}
else
{
MessageBox( L"Upload file failed" );
}
}
The bug's repro step is as following:
1. Click the button, and now the file is being transfered.
2. Disable the network connection.
3. Upload file failed is shown.
4. Enable the network connection.
5. Click the button again.
Expect behavior:
1. Messagebox "Login Succeeded" shown.
2. File is transferred.
3. MessageBox "Upload file succeeded" shown.
Actual behavior:
1. Messagebox "Login Succeeded" shown.
2. Messagebox "Upload file failed" shown.
3. Netstat shows that every retry will leave a Listening port there, if you close the process, all opening port disapperred.
I have retried for 30 times, each of two have 30 seconds interval. It still does not working.
I tried to use command line ftp to connect the server and put a file, it works.
So I think there is something not cleared when the network is unpluged, am I right?
The internal error I receive is "Internal Error: Receive timeout error :\generalv\gvclient\generalv\ftpclient_demo\ftpclient.cpp:1,102 files.."
At the same time, by "net state /a" I found the listening port of my pc is become more and more.
Therefore, it is a resource leak? or I have some thing wrong in using it?
Thanks,
Mingju
-- modified at 4:44 Friday 15th June, 2007
|
|
|
|
|
You are right. There is a bug in the CBlockingSocket class. Add the following destructor to the file "BlockingSocket.cpp".
CBlockingSocket::~CBlockingSocket()<br />
{<br />
Cleanup();<br />
}<br />
|
|
|
|
|
Thanks man,
You are the one!
|
|
|
|
|
Hello!
Does anyone make a unix port of this nice class yet? I tried but failed. Would be nice if anyone has done and could provide it.
|
|
|
|
|
In the DevCPP project there is a wrong linker library added. The one in the current project is a library from Visual Studio. You should use the libws2_32.a from MinGW compiler if you use MinGW.
grtz
|
|
|
|
|
Too late reply, but may help some readers:
Open your project linker parameters and add following
-lwininet -lwsock32
and discard existing vc7 library name, I got it working this way.
regards
easy GUI building www.radcpp.com
|
|
|
|
|
I am using classes to implement blocking TCP/IP sockets in an existing MFC app.
Noticed that 'virtual void GetPeerAddr(LPSOCKADDR psa) const = 0;' is missing in declaration of class IBlockingSocket in BlockingSocket.h
Everything else is working great! thx
|
|
|
|
|
when i try to upload files to the server that does not sopport port 21,it doesn't work!
how can i do to solve this problem?thank you.
|
|
|
|
|
Following is an example that using port 1234.
nsFTP::CFTPClient ftpClient(nsSocket::CreateDefaultBlockingSocketInstance(), 30);
nsFTP::CLogonInfo loginInfo;
loginInfo.SetHost(static_cast<lpctstr>(_T("192.168.1.50")), static_cast<ushort>(1234),
static_cast<lpctstr>(_T("user")), static_cast<lpctstr>(_T("passwd")),
static_cast<lpctstr>(_T("")));
bool hr = false;
hr = ftpClient.Login( loginInfo );
if ( hr )
{
MessageBox( L"Login Succeeded" );
}
else
{
MessageBox( L"Login Failed" );
}
if ( hr )
{
hr = ftpClient.UploadFile( _T("d:/ff.txt"), _T("2.txt") );
}
|
|
|
|
|
Hi all,
I use VS 6.0 Enterprise and got follow warnings and errors during compile FTPClient.cpp
Warning (112):
Compiler Warning (level 1) C4786
'identifier' : identifier was truncated to 'number' characters in the debug information
Error (abort compile) - I think thats a result from warnings.
Fatal Error C1063
compiler limit : compiler stack overflow
I don't know what can I do now. Need a hot tip.
Thanks for help.
Guru
|
|
|
|
|
hi! My name is JC im from Puerto Rico. Right now my C++ knowledge is a bit "limited"
and Im developing an application tthat will end up updating a txt file in an FTP. Your class got the perfect functions i need. Exactly what i need for my progrm to work is this:
nsFTP::CFTPClient ftpClient;
nsFTP::CLogonInfo logonInfo("localhost", 21, "anonymous",
"anonymous@user.com");
// connect to server
ftpClient.Login(logonInfo);
// do file operations
ftpClient.DownloadFile("/pub/test.txt", "c:\\temp\\test.txt");
ftpClient.UploadFile("c:\\temp\\test.txt", "/upload/test.txt");
// disconnect
ftpClient.Logout();
dat is basically all i need BUT your work is very hard to understand for me and i just dont know WHAT to include and where to include.. Id appreciate any help you can give me. Thanks in advance
-JC
|
|
|
|
|
can anyone give me the approach to download a file from a ftp server using multithreding. (i.e. separate threads for downloading simultaneously USING JAVA)
VIVEK
lathi
|
|
|
|
|
I have compiled your FTP Client Class successfully with msvc6.0,and it works wonderfully. Good work!
but I need to support IPv6 about this Class,can you suggest me something about this?
|
|
|
|
|
I have noticed that if the connection is lost during the upload process, instead of giving a time out message or any other appropriate error, the application will simply crash.
Do you recommend a course of action for more appropriately handling this problem?
-Mike
|
|
|
|
|
I have tried to reproduce the error but the application never crashes (one time the ftp-server crashed). I have tried it several times. The client always displayed an error message (e.g. timeout). Can you reproduce the error on your machine?
To which server have you connected? Is it a public server (so I can connect to it)?
Can you mail me a screenshot of the call stack?
|
|
|
|
|
I get some redefinitions and missings. After the next includes in Definements.h it works:
#include <time.h>
#include <assert.h>
Best regards
Stephan
|
|
|
|
|
Hello,
I created a new console project with VC7 and added the sources from the console example project.
Trying to compile, the compiler throws a lot of redefinition errors, something like:
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\Include\WinSock2.h(2233) : error C2375: 'WSAStartup': redefinition; different basic types
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\PlatformSDK\Include\WinSock2.h(2268) : error C2375: 'WSASetLastError': redefinition; different basic types
etc.
Who knows what I did wrong and how can I solve this problem.
Thanks for your help,
regards,
mvp
|
|
|
|
|
can anybody tell me?
anyway, thanks.
|
|
|
|
|
Resuming is enabled by default. With SetResumeMode you can turn on/off resuming. If resuming is enabled, then there will be a lookup if the target file exists. If it exists then the new offset will be set with Restart method and only the remaining bytes will be downloaded and added to the target file.
|
|
|
|
|
It is me again.
I had waited this new version with big interest.
Some features are very useful, such a new form of listeners(CNotification) and many other ...
I have ideas, which can make your class more powerful.
1) I think that 32-bit size variable lReceivedBytes must be in CNotification.
at now file with size more 4 GB are wide-spread (DVD iso for example ... ).
2) Class is designed for multi-thread enviroment, but does not use this power completely.
I think that threads-pool technology will apropos in this case.
Creating some one class "FTPPool" can make your component best,than others.
Enjoy you.
|
|
|
|