Hello all
kindof a noob here but Im having an issue with trying to write a class that allow me to create a method for socket handle reuse but its not working so good I can always create the directory but when I goto write the file I get handle invalid errors, its definately a handle issue Im thinking im missing something obvious here can anybody help, here is the basic pseudo code of what im trying to do.
class FTPjunk
{
public:
FTPjunk();
HINTERNET hOpenHandle;
HINTERNET hConnectionHandle;
bool SetHandles(char* mode);
bool CreateDirectory(char* directory_name);
bool FTPjunk::WriteFile(char* file_name);
private:
~FTPjunk();
}
FTPjunk::FTPjunk()
{
HINTERNET hOpenHandle = null;
HINTERNET hConnectionHandle = null;
}
FTPjunk::~FTPjunk()
{
}
bool FTPjunk::SetHandles(char * mode)
{
if(mode == "OPEN") {
hOpenHandle = InternetOpen(lpszAgent,
dwAccessType,
lpszProxyName,
lpszProxyBypass,
dwFlags);
hConnectionHandle = InternetConnect(hOpenHandle,
lpszServerName,
nServerPort,
lpszUsername,
lpszPassword,
dwService,
dwflags,
0);
}
else if(mode == "CLOSE") {
InternetCloseHandle(hOpenHandle);
InternetCloseHandle(hConnectionHandle);
}
}
bool FTPjunk::CreateDirectory(char* directory_name);
{
SetHandles("OPEN");
FtpCreateDirectory(hConnectionHandle, directory_name);
SetHandles("CLOSE");
return true;
}
bool FTPjunk::WriteFile(char* file_name);
{
SetHandles("OPEN");
FtpPutFile(hConnectionHandle,
file_name,
file_name,
dwflags,
0);
SetHandles("CLOSE");
}
}
int main()
{
FTPjunk ftpjunk = new FTPjunk();
ftpjunk->CreateDirectory("test_directory");
ftpjunk->WriteFile("test_file");
return 0;
}
kindof a noob here but Im having an issue with trying to write a class that allow me to create a method for socket handle reuse but its not working so good I can always create the directory but when I goto write the file I get handle invalid errors, its definately a handle issue Im thinking im missing something obvious here can anybody help, here is the basic pseudo code of what im trying to do.
class FTPjunk
{
public:
FTPjunk();
HINTERNET hOpenHandle;
HINTERNET hConnectionHandle;
bool SetHandles(char* mode);
bool CreateDirectory(char* directory_name);
bool FTPjunk::WriteFile(char* file_name);
private:
~FTPjunk();
}
FTPjunk::FTPjunk()
{
HINTERNET hOpenHandle = null;
HINTERNET hConnectionHandle = null;
}
FTPjunk::~FTPjunk()
{
}
bool FTPjunk::SetHandles(char * mode)
{
if(mode == "OPEN") {
hOpenHandle = InternetOpen(lpszAgent,
dwAccessType,
lpszProxyName,
lpszProxyBypass,
dwFlags);
hConnectionHandle = InternetConnect(hOpenHandle,
lpszServerName,
nServerPort,
lpszUsername,
lpszPassword,
dwService,
dwflags,
0);
}
else if(mode == "CLOSE") {
InternetCloseHandle(hOpenHandle);
InternetCloseHandle(hConnectionHandle);
}
}
bool FTPjunk::CreateDirectory(char* directory_name);
{
SetHandles("OPEN");
FtpCreateDirectory(hConnectionHandle, directory_name);
SetHandles("CLOSE");
return true;
}
bool FTPjunk::WriteFile(char* file_name);
{
SetHandles("OPEN");
FtpPutFile(hConnectionHandle,
file_name,
file_name,
dwflags,
0);
SetHandles("CLOSE");
}
}
int main()
{
FTPjunk ftpjunk = new FTPjunk();
ftpjunk->CreateDirectory("test_directory");
ftpjunk->WriteFile("test_file");
return 0;
}