Sha256: fa3439ec0db184167b8236d9e5f0b1ea7cf11353690bf2fd1c5baa16ac2a1627

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

#include "ev_dispatch.h"
#include "ev_http.h"

using namespace EVD;


// catch SIGINT to kill process 
static void  SIGINT_handler(int sig)
{
  exit(sig);
}

int main(int argc, char **argv)
{
  Dispatch dispatcher;

  if (signal(SIGINT, SIGINT_handler) == SIG_ERR) {
    printf("SIGINT install error\n");
    exit(1);
  }

  if( !dispatcher.start() ){
    fprintf( stderr, "Failed to start up dispatcher\n" );
    return 1;
  }

  printf( "dispatcher thread running...\n" );

  request_t yahoo_id = dispatcher.request( new HttpRequest( dispatcher, "http://www.yahoo.com/" ) );
  request_t google_id = dispatcher.request(new HttpRequest( dispatcher, "http://www.google.com/" ) );
  printf("yahoo: %d\n", yahoo_id);
  printf("google: %d\n", google_id);

  Response *res = NULL;

  while( dispatcher.wait_for_response_by_id( yahoo_id, Timer(1,5) ) ){
    printf("waiting for yahoo...\n");
  } 
  res = dispatcher.response_for( yahoo_id );
  printf("Recieved response from yahoo: %s, Content-Length: %d\n", res->name.c_str(), res->body.length() );
  delete res;

  while( dispatcher.wait_for_response_by_id( google_id, Timer(1,5) ) ){
    printf("waiting for google...\n");
  } 

  res = dispatcher.response_for( google_id );
  printf("Recieved response from google: %s, Content-Length: %d\n", res->name.c_str(), res->body.length() );
  delete res;

  return 0;
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
evdispatch-0.1.4 ext/revdispatch/libdispatch-0.1/test/key_test.cc
evdispatch-0.2.0 ext/revdispatch/libdispatch-0.1/test/key_test.cc
evdispatch-0.2.1 ext/revdispatch/libdispatch-0.1/test/key_test.cc
evdispatch-0.2.2 ext/revdispatch/libdispatch-0.1/test/key_test.cc
evdispatch-0.1.5 ext/revdispatch/libdispatch-0.1/test/key_test.cc