Closed sebt3 closed 6 years ago
Thank you. I'm occupied at the moment, but I'll look into this next week.
Can you not make two server objects, one listening on 80 and the other on 443 for example (start them each in a thread)?
Same problem, I must have two different ports with different services but the service with the lower port number never anwers. The problem is that acceptor.async_accept()
never wake up...
@killoctal here is an example with two servers running on two different ports:
#include "server_http.hpp"
using namespace std;
using HttpServer = SimpleWeb::Server<SimpleWeb::HTTP>;
int main() {
HttpServer server1;
server1.config.port = 8080;
server1.resource["^/$"]["GET"] = [](shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> /*request*/) {
response->write("test1");
};
HttpServer server2;
server2.config.port = 8081;
server2.resource["^/$"]["GET"] = [](shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Request> /*request*/) {
response->write("test2");
};
thread server1_thread([&server1]() {
// Start server 1
server1.start();
});
thread server2_thread([&server2]() {
// Start server 2
server2.start();
});
server1_thread.join();
server2_thread.join();
}
Hi I am sorry It was not working because I had an old legacy code hidden in the darkness which was already using the port. Now it works Best regards Gabriel
Hi,
currently the code allow to listen on a single pair<address, port>. It would be nice to actually be able to use more than one.