Last active
August 28, 2015 16:32
-
-
Save nileshgr/10f4bcb7b8b370966dc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fcgio.h> | |
#include <asio.hpp> | |
#include <thread> | |
#include <unistd.h> | |
#include <string> | |
#define FCGI_SOCKET "/tmp/fcgi_socket" | |
void hello(asio::local::stream_protocol::socket& sock) { | |
std::string msg = "Hello World\n"; | |
asio::write(sock, asio::buffer(msg)); | |
sleep(10); | |
} | |
int main() { | |
::unlink(FCGI_SOCKET); | |
using namespace asio::local; | |
asio::io_service fcgi_ioservice; | |
stream_protocol::endpoint fcgi_endpoint(FCGI_SOCKET); | |
stream_protocol::socket fcgi_socket(fcgi_ioservice); | |
stream_protocol::acceptor fcgi_acceptor (fcgi_ioservice, fcgi_endpoint); | |
while(true) { | |
fcgi_acceptor.accept(fcgi_socket); | |
std::thread t1 (hello, std::ref(fcgi_socket)); | |
t1.join(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment