开发者

How to listen for browser requests with POCO and c++

I would like to know what Poco classes to use in listening for a browser request. This is for a proxy server. In general I want to open a port and wait for a request from a browser. Please give an example as I'm quite new to Poco and C++ in g开发者_如何学编程eneral.


You can look at the HTTPTimeServer (http://pocoproject.org/docs/00100-GuidedTour.html#4) example. Basically you need:

  • Poco::Util::ServerApplication. You derive from this class to host the server process.
  • Poco::Net::ServerSocket to handle the socket to listen at.
  • Poco::Net::HTTPServer which is in charge of accepting connections and dispatching them to HTTPRequestHandler derived instances.
  • Poco::Net::HTTPServerParams that tell the server the number of threads and the size of the connection backlog.
  • Poco::Net::HTTPRequestHandler. You derive from this class to handle requests.
  • Poco::Net::HTTPRequestHandlerFactory. You derive from this class to create handler instances.
  • Poco::Net::HTTPServerRequest which contains the information in the request (i.e. headers, body, cookies, authentication).
  • Poco::Net::HTTPServerResponse. You populate an instance of this class with response information such as headers and body.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜