[9874] in www-talk@info.cern.ch
Re: Receiving requests
daemon@ATHENA.MIT.EDU (Luke Gonze)
Mon Mar 25 12:00:09 1996
Date: Mon, 25 Mar 1996 11:05:12 -0500 (EST)
From: Luke Gonze <applix!luke@uunet.uu.net>
To: applix!uunet!w3.org!www-talk@uunet.uu.net
In-Reply-To: <199603241956.OAA13162@www19.w3.org>
Resent-From: www-talk@w3.org
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 ---