net/clientnb.cpp | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)
New commits: commit 0c39cd017feb544f14acb253f6c3788ad43cccc5 Author: Michael Meeks <[email protected]> Date: Thu Feb 16 11:43:30 2017 +0000 Thread to poke server. diff --git a/net/clientnb.cpp b/net/clientnb.cpp index 87ee8b5..822804d 100644 --- a/net/clientnb.cpp +++ b/net/clientnb.cpp @@ -34,6 +34,8 @@ #include <Poco/Util/HelpFormatter.h> #include <Poco/Util/Option.h> #include <Poco/Util/OptionSet.h> +#include <Poco/Runnable.h> +#include <Poco/Thread.h> using Poco::Net::HTTPClientSession; using Poco::Net::HTTPRequest; @@ -86,11 +88,11 @@ struct Session Poco::Net::HTTPResponse response; try { - std::cerr << "try to get response\n"; +// std::cerr << "try to get response\n"; std::istream& responseStream = _session->receiveResponse(response); std::string result(std::istreambuf_iterator<char>(responseStream), {}); - std::cerr << "Got response '" << result << "'\n"; +// std::cerr << "Got response '" << result << "'\n"; number = std::stoi(result); } catch (const Poco::Exception &e) @@ -103,8 +105,35 @@ struct Session } }; +struct ThreadWorker : public Runnable +{ + const char *_domain; + ThreadWorker (const char *domain) + : _domain(domain) + { + } + virtual void run() + { + for (int i = 0; i < 100; ++i) + { + Session ping(_domain); + ping.sendPing(i); + int back = ping.getResponse(); + assert(back == i + 1); + } + } +}; + struct Client : public Poco::Util::Application { + void testLadder() + { + ThreadWorker ladder("init"); + Thread thread; + thread.start(ladder); + thread.join(); + } + public: int main(const std::vector<std::string>& /* args */) override { @@ -121,6 +150,8 @@ public: back = second.getResponse(); assert (back == count + 2); + testLadder(); + return 0; } }; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
