Dear all,
I am still new to http & cppcms, so pls bear with me. When I try to test multiple request multiple connections on cppcms I am recieving a lot of read errors. I tried to program the url mapping hello world into asynchronous but I was still getting the same read errors when I tested it with `wrk` program.
What am I doing wrong? Pls help.
If it matters, Here is the command I used for wrk
`./wrk -t 1 -c 1 -d5s http://localhost:8080/hello`
While this is the async url mapping hello world.
`#include <cppcms/application.h>
#include <cppcms/service.h>
#include <cppcms/http_response.h>
#include <cppcms/url_dispatcher.h>
#include <cppcms/url_mapper.h>
#include <cppcms/applications_pool.h>
#include <iostream>
#include <stdlib.h>
#include <booster/intrusive_ptr.h>
#include <cppcms/applications_pool.h>
#include <cppcms/http_request.h>
#include <cppcms/http_context.h>
#include <set>
#ifdef USE_STD_TR1_BIND
#include <tr1/functional>
using std::tr1::bind;
#elif defined USE_STD_BIND
#include <functional>
using std::bind;
#endif
class hello: public cppcms::application {
public:
hello(cppcms::service &srv) :
cppcms::application(srv)
{
dispatcher().assign("/number/(\\d+)",&hello::number,this,1);
mapper().assign("number","/number/{1}");
dispatcher().assign("/smile",&hello::smile,this);
mapper().assign("smile","/smile");
dispatcher().assign("",&hello::welcome,this);
mapper().assign("");
mapper().root("/hello");
}
void number(std::string num)
{
int no = atoi(num.c_str());
response().out() << "The number is " << no << "<br/>\n";
response().out() << "<a href='" << url("/") << "'>Go back</a>";
}
void smile()
{
response().out() << ":-) <br/>\n";
response().out() << "<a href='" << url("/") << "'>Go back</a>";
}
void welcome()
{
response().out() <<
"<h1> Wellcome To Page with links </h1>\n"
"<a href='" << url("/number",1) << "'>1</a><br>\n"
"<a href='" << url("/number",15) << "'>15</a><br>\n"
"<a href='" << url("/smile") << "' >:-)</a><br>\n";
}
};
int main(int argc,char ** argv)
{
try {
cppcms::service service(argc,argv);
booster::intrusive_ptr<hello> c=new hello(service);
service.applications_pool().mount(c);
service.run();
}
catch(std::exception const &e) {
std::cerr<<"Catched exception: "<<e.what()<<std::endl;
return 1;
}
return 0;
}
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4`
|