On Wednesday, April 07, 2010 11:11 AM Dean Michael Berris wrote:

>A more complete listing would definitely help me debug it or reproduce at 
>least.


In my experience in the past, it wasn't possible to bind two sockets to the 
same port- it caused an error, which makes sense to me.  I'm running this 
example on Windows XP with MSVC2008

Thanks

Erik


********************


#include <boost/network/protocol/http/server.hpp>
#include <boost/thread/thread.hpp>
#include <iostream>


namespace http = boost::network::http;

struct goodbye_world {
    void operator() (http::server<goodbye_world>::request const &request,
                     http::server<goodbye_world>::response &response) {
        response = http::server<goodbye_world>::response::stock_reply(
            http::server<goodbye_world>::response::ok, "Goodbye, World!");
    }
    void log(...) {}
};


struct ThreadServer
{
   ThreadServer(const char* hostname, const char* port) : server(hostname, 
port, handler) {}
   goodbye_world handler;
   http::server<goodbye_world> server;
   void thread_func()
   {
      server.run();
   }
};

struct hello_world {
    void operator() (http::server<hello_world>::request const &request,
                     http::server<hello_world>::response &response) {
        response = http::server<hello_world>::response::stock_reply(
            http::server<hello_world>::response::ok, "Hello, World!");
    }
    void log(...) {}
};


int main(int argc, char * argv[]) {
    try {
       ThreadServer thread_server("localhost", "3000");
       boost::thread thread_(boost::bind(&ThreadServer::thread_func, 
boost::ref(thread_server)));
       hello_world handler;
       http::server<hello_world> server("localhost", "3000", handler);
       server.run();
       thread_.join();
    }
    catch (std::exception &e) {
        std::cerr << e.what() << std::endl;
    }
}

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Cpp-netlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cpp-netlib-devel

Reply via email to