W3C home > Mailing lists > Public > www-lib@w3.org > October to December 1998

Simultaneous requests in a gateway application

From: Mikhail Grouchinski <mgrouch@usa.net>
Date: 14 Dec 1998 14:00:07 -0000
Message-ID: <19981214140007.18562.qmail@findmail.com>
To: www-lib@w3.org
Please help...
I need to issue a non-blocking request from
event callback. 
This source is a skeleton for a gateway.
It should read from one socket (via custom protocol) and talk to the rest of the world via HTTP. Any requests don't block and replies are processed as they come. The gateway should keep track what reply coresponds to a particular request.

Please see comments in this source.
Thank you

#include <stdio.h>

#include "WWWLib.h"
#include "WWWInit.h"

#ifdef LIBWWW_SHARED
#include "HTextImp.h"
#endif

#define APP_NAME  "HttpGw"
#define APP_VER   "1.0"

PRIVATE HTEvent * FdEvent = NULL;

PRIVATE int process(int fd, void * param, HTEventType type)
{
    char        c;
    HTRequest * request = NULL;
/*    HTChunk *   chunk = NULL;  */

    c = getchar();
    if (c == '\n')  return HT_OK;

    printf("%c process_fd\n", c);

    if (c == '1')  {
       request = HTRequest_new();
 
/*
How can I issue a non-blocking request here?
It should be handled within the main event loop.
It shouldn't block here.
How can I register callback for the reply here?
*/        

       }
    }  else
    if (c == '2')  {
    }

    return HT_OK;
}

int main (int argc, char ** argv)
{
    int     fd = STDIN_FILENO;
    char *  context = NULL;
    int     to = -1;
    int     status = 1;

    WWWTRACE = SHOW_ALL_TRACE;    

    HTProfile_newNoCacheClient(APP_NAME, APP_VER);

/*
What is context?
Is it the second parameter that I get in a callback 'process'?

*/

    FdEvent = HTEvent_new(process, context, HT_PRIORITY_MAX, to);
    HTEventList_register(fd, HTEvent_READ, FdEvent);

    if (status) HTEventList_loop(NULL);

    return 0;
}
Received on Monday, 14 December 1998 09:00:17 EST

This archive was generated by hypermail pre-2.1.9 : Wednesday, 3 September 2003 17:59:24 EDT