Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 362
  • Last Modified:

Get method using indy 9 component

Hi! I'am using an indy 9 component to do a get method. But if any problem occur like read time out the next requests doesn't anything. Have I gotta do anything when it happen like disconnect or close?
0
directcall
Asked:
directcall
  • 2
1 Solution
 
kode99Commented:
Yes,  you should use catch the exception and shut down the socket something like this,
 
  AnsiString sURL = "<address>";
  TMemoryStream *ResultMS;

    try
    { // Get Method with a memory stream to load the result into
      HTTP->Get(sURL, ResultMS);
    }
    catch(Exception& e)
    {
      AnsiString sErrorMsg = e.Message;     // maybe do something here with the error message
      HTTP->DisconnectSocket();
    }

You use DisconnectSocket() to force the socket to clear.  There is also a Disconnect() method but DisconnectSocket is recommended to clear a socket after errors.  Check the indy help file for a more detailed explaination of the differences.


0
 
George TokasCommented:
One more oppinion....
I like beter the THTTP component when I have to deal with Get property...
If an error occurs you will see it at the Header property and the connection is cleared immediatetly...
There was a time I made an app with Indy component IdTime, THTTP, and CppWebBrowser component to do a task...
3 different components to do a task someone else could do with only one, not to mention the slight delay especially in slow machines...
So.. What I mean is that sometimes we (programmers) have to use some other techniques to bypass problems occured...:-)

gtokas.
0
 
directcallAuthor Commented:
I can´t use THTTP component because it doesn´t authentication method. The indy 9 has it.
0
 
George TokasCommented:
Information:
TCppWebBrowser can be used with the options you want...:-)
BUT to find your way to use it could be hell and waste of precious time...:-)
I'm working with it for 3 years now and still trying to do what I have to with it...
Thats why I wrote in my post about 3 components...

gtokas.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now