W3C home > Mailing lists > Public > www-talk@w3.org > March to April 1996

Re: Receiving requests

From: Luke Gonze <applix!luke@uunet.uu.net>
Date: Mon, 25 Mar 1996 11:05:12 -0500 (EST)
To: applix!uunet!w3.org!www-talk@uunet.uu.net
Message-Id: <Pine.SUN.3.91.960325110007.4111D-100000@darkness>

This works for receiving requests from a browser.  I haven't tested it in 
a real industrial strength situation yet.  The first thing you'd need to 
improve is to handle requests larger than BUFSIZE.

#define BUFSIZE 10000
int reader(int fd)
{
    char buf[BUFSIZE+1];
    char *bptr = buf;
    int n;
    int buflen;

    buflen = BUFSIZE;

    /* read the string itself */
    while( (n = read(fd, bptr, buflen)) > 0){
        bptr[n] = '\0';
        bptr += n;
        buflen -= n;
    }
    /* if the output of this looks funny, by the way, keep in mind that
       ^M is ascii 13 */
    printf("read from httpd server: \n%s\n",buf);

    if( buflen == BUFSIZE )
        return(n);
    else
        return(BUFSIZE - buflen);
}


--- Luke Gonze --- luke@applix.com --- 
--- Software Engineer, Applix Espresso project ---
Received on Monday, 25 March 1996 11:56:38 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 27 October 2010 18:14:19 GMT