wxHTTP wxPROTO_CONNERR error Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
ComFreek
Knows some wx things
Knows some wx things
Posts: 30
Joined: Wed Jun 09, 2010 1:13 pm

wxHTTP wxPROTO_CONNERR error

Post by ComFreek »

Hello,

I have again a problem :D

I want to get a file from the internet:

Code: Select all

wxHTTP *http = new wxHTTP;
wxInputStream *in = http->GetInputStream(wxT("http://www.example.com"));
if (http->GetError()!=wxPROTO_NOERR)
{
  wxMessageBox(wxT("Error!"), wxT(""), wxOK);
  wxMessageBox(wxString::Format(wxT("%d"), (int)http->GetError()), wxT(""), wxOK);
}
wxString OutputData;
if (in && in->IsOk())
{
  wxStringOutputStream OutputStream(&OutputData);
  in->Read(OutputStream);
  wxMessageBox(OutputData, wxT(""), wxOK);
}
(In the OnInit function of the app, I have registered the wxInternetFSHandler.)

I get always the error wxPROTO_CONNERR (error code 3).
My firewall had already been deactivated and I had run the program as administrator but there is the same problem!

I hope someone can help me.
Thanks!!

Regards
ComFreek

PS: I have built wxWidgets as a DLL and a monolithic library.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax »

I think you need a Connect() call first. Check this sample:
http://forums.wxwidgets.org/viewtopic.php?p=63331#63331
Use the source, Luke!
ComFreek
Knows some wx things
Knows some wx things
Posts: 30
Joined: Wed Jun 09, 2010 1:13 pm

Post by ComFreek »

Thank you for your answer.

I have modified the code:

Code: Select all

wxHTTP http;
http.Connect(wxT("wxforum.shadonet.com"));
wxInputStream* ins = http.GetInputStream(wxT("viewtopic.php?p=63331#63331"));
if( ins )
{
  wxFileOutputStream outs( wxT("testout.txt"));
  ins->Read(outs);
  outs.Close();
}
else
{
      wxMessageBox(wxString::Format(wxT("%d"), (int)http.GetError()), wxT(""), wxOK);
}
Now I get the error wxPROTO_NOFILE (6) "The remote file doesn't exist.".
But the file exists (it works with www.google.com and index.html)! Why doesn't that work?
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax »

Try with a "/" at the beginning of the path ( "/viewtopic ..." ) and/or without the "#63331".
Use the source, Luke!
ComFreek
Knows some wx things
Knows some wx things
Posts: 30
Joined: Wed Jun 09, 2010 1:13 pm

Post by ComFreek »

doublemax, thanks a lot, it works!!
I had to add the "/" at the beginning of the path.
Post Reply