Click here to Skip to main content
15,890,506 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Question3D Objects Pin
Lampros Giampouras26-Feb-07 12:21
Lampros Giampouras26-Feb-07 12:21 
AnswerRe: 3D Objects Pin
Waldermort26-Feb-07 15:48
Waldermort26-Feb-07 15:48 
AnswerRe: 3D Objects Pin
Lampros Giampouras27-Feb-07 3:54
Lampros Giampouras27-Feb-07 3:54 
QuestionMetafile antialising in Gdiplus Pin
Swinefeaster26-Feb-07 10:10
Swinefeaster26-Feb-07 10:10 
QuestionConversion of Unsigned __int64 to binary does not work in 2003 Pin
AAKAra26-Feb-07 9:02
AAKAra26-Feb-07 9:02 
AnswerRe: Conversion of Unsigned __int64 to binary does not work in 2003 Pin
Mark Salsbery26-Feb-07 9:19
Mark Salsbery26-Feb-07 9:19 
GeneralRe: Conversion of Unsigned __int64 to binary does not work in 2003 Pin
AAKAra26-Feb-07 10:00
AAKAra26-Feb-07 10:00 
QuestionHandle Reuse Problems? [modified] Pin
V3RO26-Feb-07 7:50
V3RO26-Feb-07 7:50 
Hello all
Im having an issue with trying to write a class that allows 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(specifically the hConnectionHandle), its definately a handle issue. Im thinking im missing some obvious and important step here can anybody help, here is the basic pseudo code of what im trying to do.

I do not have my original code to post for Debug, but below shows all the steps I took to try and reuse the HANDLES minus any exception handling and debugging routines. Im trying to see if anyone has done something like this before and can point out where I'm missing a step or off base or what?

again the error always was an invalid handle (hConnectionHandle)on second reuse in WriteFile each and everytime.


class FTPjunk
{
   public:
          FTPjunk();
          HINTERNET hOpenHandle;
          HINTERNET hConnectionHandle;
          bool SetHandles(string mode);
          bool CreateDirectory(string directory_name);
          bool FTPjunk::WriteFile(string file_name);
   private:
          ~FTPjunk();
};


FTPjunk::FTPjunk()
{
   hOpenHandle = null;
   hConnectionHandle = null;
}

FTPjunk::~FTPjunk()
{
}

bool FTPjunk::SetHandles(string 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(string directory_name);
{
    SetHandles("OPEN");
    FtpCreateDirectory(hConnectionHandle, directory_name);
    SetHandles("CLOSE");
    return true;
}

bool FTPjunk::WriteFile(string 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;

}




-- modified at 15:13 Monday 26th February, 2007
AnswerRe: Handle Reuse Problems? Pin
Mark Salsbery26-Feb-07 9:08
Mark Salsbery26-Feb-07 9:08 
GeneralRe: Handle Reuse Problems? Pin
V3RO26-Feb-07 9:15
V3RO26-Feb-07 9:15 
GeneralRe: Handle Reuse Problems? Pin
V3RO26-Feb-07 9:45
V3RO26-Feb-07 9:45 
GeneralRe: Handle Reuse Problems? Pin
Mark Salsbery26-Feb-07 10:16
Mark Salsbery26-Feb-07 10:16 
QuestionAccessing DLL Pin
vinith26-Feb-07 7:28
vinith26-Feb-07 7:28 
AnswerRe: Accessing DLL Pin
Mark Salsbery26-Feb-07 7:41
Mark Salsbery26-Feb-07 7:41 
GeneralRe: Accessing DLL Pin
vinith26-Feb-07 23:03
vinith26-Feb-07 23:03 
QuestionRe: Accessing DLL Pin
prasad_som26-Feb-07 19:48
prasad_som26-Feb-07 19:48 
QuestionMS Access Pin
shiraztk26-Feb-07 6:32
shiraztk26-Feb-07 6:32 
QuestionRe: MS Access Pin
David Crow26-Feb-07 9:04
David Crow26-Feb-07 9:04 
QuestionWhite space increased and one reference number jumped in simple console application Pin
Software_Specialist26-Feb-07 4:31
Software_Specialist26-Feb-07 4:31 
QuestionRe: White space increased and one reference number jumped in simple console application Pin
Newbie0026-Feb-07 6:24
Newbie0026-Feb-07 6:24 
AnswerRe: White space increased and one reference number jumped in simple console application Pin
Software_Specialist27-Feb-07 9:38
Software_Specialist27-Feb-07 9:38 
GeneralRe: White space increased and one reference number jumped in simple console application Pin
Newbie0028-Feb-07 3:28
Newbie0028-Feb-07 3:28 
QuestionMS Access ActiveX VC++ Pin
shiraztk26-Feb-07 3:58
shiraztk26-Feb-07 3:58 
AnswerRe: MS Access ActiveX VC++ Pin
James R. Twine26-Feb-07 4:16
James R. Twine26-Feb-07 4:16 
GeneralRe: MS Access ActiveX VC++ Pin
shiraztk26-Feb-07 4:35
shiraztk26-Feb-07 4:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.