Ciao ragazzi, inanzitutto mi scuso con i moderatori se questa è la sezione sbagliata del forun, ma mi serbrava lam più giusta.

Ebbene io stabilisco al mio dominio una connessione FTP con due PC.
Il problema è il seguente:

PC1 stabilisce una connessione, upload un file supponiamo di 5 megabyte.
PC2 vuole scaricare il file che sta caricando PC1, ma come fa a sapere quando PC1 ha completato di caricare il file???

Attualmente utilizzo il C++ per caricare e scaricare file via FTP, ma posso anche implementare delle funzioni PHP che dicono quando il file è disponibile o no.

Sinceramente penso che esista una soluzione migliore senza passare al secondo metodo.




Codice per la connessione FTP in C++
Codice PHP:
bool AddFileToServer(string buffer, string file)/*string directory = "tree" for default*/
{
HINTERNET hInternet;
HINTERNET hFtpSession;

hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);

if(
hInternet == NULL)
return
false;
hFtpSession = InternetConnect(hInternet,"www.dominio.com",INTERNET_DEFAULT_FTP_PORT, "nome_utente","password", INTERNET_SERVICE_FTP, 0,0 );
if(
hFtpSession == NULL)
{
int i = GetLastError();

DWORD dwError;
char error [500];
DWORD dwSize = sizeof(error);
InternetGetLastResponseInfo(&dwError,error,&dwSize);
return
false;
}
char this_exe_path [600];
GetModuleFileName(NULL,this_exe_path,600);

string temp_file_path = this_exe_path;

int found = temp_file_path.find_last_of('\');
temp_file_path = temp_file_path.substr(0,found);

temp_file_path += "\\temp_file";

ofstream out(temp_file_path);
out << buffer;
out.close();


string server_file_path = "";
server_file_path += file;

BOOL bRet2 = FtpPutFile(hFtpSession, temp_file_path.c_str(), server_file_path.c_str(), FTP_TRANSFER_TYPE_BINARY, 0);
DeleteFile(temp_file_path.c_str());

InternetCloseHandle(hFtpSession);
InternetCloseHandle(hInternet);

if(bRet2 == FALSE)
return false;
return true;
}
attendo aiuti grazie :)

inoltre se avete soluzioni PHP potete darmi degli esempi di codice perfavore, perché non sono molto pratico diciamo :)