microsoft / cpprestsdk

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
8.01k stars 1.66k forks source link

Does cpprest sdk support https server? #1043

Open mishra-b opened 5 years ago

mishra-b commented 5 years ago

Does this library support HTTPS server on Linux and windows and also is IPv6 supported & how to implement that?

23W commented 5 years ago

This question is interesting me also.

coolsabby7 commented 5 years ago

yes it does support HTTPS server there are examples..

coolsabby7 commented 5 years ago

Hi Have a problem with http_listener class if implemenetd the below way.

uri_builder uri(L"http://localhost:8023/");
auto addr = uri.to_string();
http_listener listener(addr);

try
{
    listener.open().then([&listener](){TRACE(L"\nstarting to listen\n"); }).wait();
    //while (true);
}
catch (exception const & e)
{
    wcout << e.what() << endl;
}

std::string line;
std::wcout << U("Hit Enter to close the listener.");
std::getline(std::cin, line);

listener.close().wait();

as per the above code the code should block after calling listener open.wait(), but the control just fall through and the above code exits as it goes out of scope. if i add the while(true) the execution blocks and the server listens. but the issue is it eats up all the CPU. I also tried putting the while(true) inside the lambda, but still the same CPU occupied.

1) is this the way wait() should behave on listener open(). 2) is there any other way apart from while(true) to block scope loose.

Any answers will be appreciated

mobileben commented 5 years ago

@coolsabby7 What I do is create a condition and have it wait on it. At least with my server, there will be no code that issues a notify to the condition.

    std::mutex              mutex;
    std::condition_variable cond;

    std::unique_lock<std::mutex> mlock(mutex);
    while (1) {
        cond.wait(mlock);
    }