Overview
Features
Download
Documentation
Community
Add-Ons & Services

NetSSL, I/O error: Socket operation attempted on non-socket

A general discussion forum.

NetSSL, I/O error: Socket operation attempted on non-socket

Postby luckhp » 30 Jun 2010, 05:42

POCO version is poco-1.3.6p2-all.

As I rewrite the download sample by using HTTPSClientSession, exception is thrown, wihich also leads to memory leak.

Code: Select all
int main(int argc, char *argv[])
{

    SharedPtr<InvalidCertificateHandler> ptrCert = new ConsoleCertificateHandler(false); // ask the user via console
    Context::Ptr ptrContext = new Context(Context::CLIENT_USE, "", "", "rootcert.pem", Context::VERIFY_RELAXED, 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
    SSLManager::instance().initializeClient(0, ptrCert, ptrContext);

    try
    {
        URI uri(argv[1]);
        HTTPSClientSession s(uri.getHost(), uri.getPort());
        s.setTimeout(Poco::Timespan(20,0)) ;
       

        //set HTTP request
        HTTPRequest req(HTTPRequest::HTTP_GET, uri.getPathAndQuery() );
        req.setVersion(HTTPRequest::HTTP_1_1) ;

        s.sendRequest(req);

        //extract the response
        HTTPResponse res;
        std::istream& rs = s.receiveResponse(res);
        std::string resp ;

        StreamCopier::copyToString(rs, resp,10240);

        if (res.getStatus() == 200)
        {
            res.write( std::cout ) ;
            std::cout << resp << std::endl ;
        }
        else
        {
            std::cout << "error: " << res.getStatus() << " " << res.getReason() << std::endl;
        }
    }
    catch (Exception& exc)
    {
       std::cerr << exc.displayText() << std::endl;
       return 1;
    }
   return 0;
}


Exception "I/O error: Socket operation attempted on non-socket" will be thrown at the end of the program.
It seems that HTTPSClientSession s is not correctly destructed, which lead to memory leak. (When I loop the
request, the memory leak will become more serious).

Could somebody help me to fix the problem? Thanks in advance.
luckhp
 
Posts: 5
Joined: 28 Jun 2010, 10:07

Re: NetSSL, I/O error: Socket operation attempted on non-socket

Postby guenter » 30 Jun 2010, 09:30

Can you reproduce this with 1.3.7?
guenter
 
Posts: 1138
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: NetSSL, I/O error: Socket operation attempted on non-socket

Postby luckhp » 02 Jul 2010, 03:53

Ok, I'll get the 1.3.7 codes and try it again.
luckhp
 
Posts: 5
Joined: 28 Jun 2010, 10:07

Re: NetSSL, I/O error: Socket operation attempted on non-socket

Postby luckhp » 02 Jul 2010, 05:31

Great! The problem is fixed in 1.3.7.

Thanks for your efficient work.
luckhp
 
Posts: 5
Joined: 28 Jun 2010, 10:07


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest