1
C - C++ / [c++] FTP upload issues
« on: April 21, 2011, 05:57:37 PM »
Hi, I am using this simple code to upload logs to ftp:
But this code ant everyone another works for me only first time. Then I have to wait about 20 min that i can get "Successfully uploaded log to ftp server!". Where is the roblem? I am on router, but I think port have to be opened. Maby this is drivehq.com problem? I am searching for alternative ftp server and try ftp.tripod.com but I don't have mind how to connect to it. So pleaz opinion or sugestion why I can't send file to ftp one after one? Thanks for you time. FileZilla and got angry on drivehq:
Status: Selected port usually in use by a different protocol.
Status: Resolving address of ftp.drivehq.com
Status: Connecting to 66.220.9.50:80...
Status: Connection attempt failed with "ECONNREFUSED - Connection refused by server".
Error: Could not connect to server
Code: [Select]
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
std::string FileName = get_date();
cout << FileName << endl;
HINTERNET hInternet;
HINTERNET hFtpSession;
hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
hFtpSession = InternetConnect(hInternet, "ftp.drivehq.com", INTERNET_DEFAULT_FTP_PORT, "user", "pass", INTERNET_SERVICE_FTP, 0, 0);
FtpPutFile(hFtpSession, "C:\\log.txt", FileName.c_str(), FTP_TRANSFER_TYPE_BINARY, 0);
if(FtpPutFile(hFtpSession, "C:\\log.txt", FileName.c_str(), FTP_TRANSFER_TYPE_BINARY, 0)){
MessageBox(NULL, "Successfully uploaded log to ftp server!", "Ftp Upload", NULL);
}else{
MessageBox(NULL, "Couldn't upload log to ftp server!", "Ftp Upload", NULL);
cout << FtpPutFile << endl; //ekrane parodo FtpPutFile
}
InternetCloseHandle(hFtpSession);
InternetCloseHandle(hInternet);
return 0;
}
But this code ant everyone another works for me only first time. Then I have to wait about 20 min that i can get "Successfully uploaded log to ftp server!". Where is the roblem? I am on router, but I think port have to be opened. Maby this is drivehq.com problem? I am searching for alternative ftp server and try ftp.tripod.com but I don't have mind how to connect to it. So pleaz opinion or sugestion why I can't send file to ftp one after one? Thanks for you time. FileZilla and got angry on drivehq:
Status: Selected port usually in use by a different protocol.
Status: Resolving address of ftp.drivehq.com
Status: Connecting to 66.220.9.50:80...
Status: Connection attempt failed with "ECONNREFUSED - Connection refused by server".
Error: Could not connect to server