Repeat usage of ofLoadURL() causes I/O error: No buffer space available

Hi guys, I am using ofLoadURL() to get a jpg image form a site. I call ofLoadURL() on the update() function. The problem is that after 30 minutes or so I start having problems related to sockets.

First I get “Net exception, address already in use” and after “I/O error: No buffer space available”. I think this is because everytime I call ofLoadURL() a new connection to the server is made and not closed properly. I may be wrong however.

Any advice about a work around?

All of this using VS2015 on Windows 10. Latest OF version.

Thanks.

Ok this is due to the ofLoadURL() function fail to close the open sockets. More everytime you call it, it opens a new instance of httpClientSession which makes another connection to the server.

My work around was to add theses lines to end of the handleRequest function:

ofHttpResponse ofURLFileLoaderImpl::handleRequest(ofHttpRequest request) 
{
    (...)
    resp = ofHttpResponse(request, *rs, res.getStatus(), res.getReason());
    httpSession->socket().close();
    return resp;
}

can you open an issue on github?

I’m not really good using github but I’ll try.

I think it is an easy fix that will enable someone to call the function
repeatedly without an issue.

Opened an issue on github -> #5149

Thanks.