wxURL not working in 2.8.0

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
javastro
In need of some credit
In need of some credit
Posts: 2
Joined: Sat Dec 16, 2006 8:45 am

wxURL not working in 2.8.0

Post by javastro »

I had a piece of code to retrieve an HTML page from Internet that worked in 2.6.3 and now it doesn't work in 2.8.0. It was built around wxURL and the snippet provided in the documentation for GetInputStream. It is actually the call to this method that is failing, returning a null pointer.

I've also noticed that the sockets sample is not working for me in 2.8.0.

I've loooked through the sources without being able to find a reason or solution. Does anybody have a workaround?. Thanks.
Troels
Experienced Solver
Experienced Solver
Posts: 79
Joined: Fri Jan 07, 2005 12:02 pm
Location: Denmark

Re: wxURL not working in 2.8.0

Post by Troels »

Try GetProtocol().SetFlags(wxSOCKET_NOWAIT).

http://sourceforge.net/tracker/index.ph ... tid=109863
PhoenixPl
I live to help wx-kind
I live to help wx-kind
Posts: 179
Joined: Wed Feb 15, 2006 9:26 am

Post by PhoenixPl »

I had the same problem lately. Try moving your wxURL code into second thread. It helped in my case. Still I don't understand why

Code: Select all

	wxURL url(address);
	if (url.IsOk())
	{
		url.GetProtocol().SetTimeout(20);
		wxInputStream* stream = url.GetInputStream();
		if (stream)
		{
			wxMessageBox(_("ok"));
		} else
		{
			wxMessageBox(_("faild"));
		}
	} else
	{
		...
	}
works in secondary thread, but fails to get stream in main thread.
lowjoel
Part Of The Furniture
Part Of The Furniture
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel »

I use wxHTTPEngine for all my HTTP transfers... See wxCode for that. IIRC wxURL was "deprecated" but strangely it hasn't been removed... even though it was "deprecated" since 2.5 (or 2.6, I'm not sure) :)
javastro
In need of some credit
In need of some credit
Posts: 2
Joined: Sat Dec 16, 2006 8:45 am

Post by javastro »

Warm thanks to all that so kindly replied to my initial post. None of the approaches have worked. Reading other posts I've noticed that currently it seems to exist a number of errors and unstabilities around the sockets implementation in wxWindows, and now I'm looking for some external library to do the job.

Thanks again.
three_pineapples
Earned a small fee
Earned a small fee
Posts: 21
Joined: Sun Sep 25, 2005 7:24 am
Location: Australia
Contact:

Post by three_pineapples »

I had a similar problem. I was trying to get the contents of a text document from a webserver.

The GetInputStream function returned a null pointer.

My problem was i had the calls to wxURL in a seperate thread and hadn't called wxSocketBase::Initialize() in my wxApp::OnInit() function.

That might help you (or it might not :P)
Post Reply