Sha256: ad3046a76d8bd372e6c06f5a8fcc3ea8cf98b441d4e3af62f63d82e443ddd44c

Contents?: true

Size: 1.28 KB

Versions: 5

Compression:

Stored size: 1.28 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 id1 = dispatcher.request( new HttpRequest( dispatcher, "http://127.0.0.1:4044/bytes/1000" ) );
  request_t id2 = dispatcher.request(new HttpRequest( dispatcher, "http://127.0.0.1:4044/bytes/10" ) );
  printf("1: %d\n", id1);
  printf("2: %d\n", id2);

  Response *res = NULL;

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

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

  res = dispatcher.response_for( id2 );
  printf("Recieved response from 2: %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.2.4 ext/revdispatch/libdispatch-0.1/test/key_test.cc
evdispatch-0.3.0 ext/revdispatch/libdispatch-0.1/test/key_test.cc
evdispatch-0.3.1 ext/revdispatch/libdispatch-0.1/test/key_test.cc
evdispatch-0.2.5 ext/revdispatch/libdispatch-0.1/test/key_test.cc
evdispatch-0.2.6 ext/revdispatch/libdispatch-0.1/test/key_test.cc