Added proxy base and fixed web server #1
@ -64,7 +64,7 @@
|
||||
|
||||
//----- Defines -------------------------------------------------------------
|
||||
#define BUF_SIZE 4096 // Buffer size (big enough for a GET)
|
||||
#define PORT_NUM 9080 // Port number for a Web server
|
||||
#define PORT_NUM 7080 // Port number for a Web server
|
||||
|
||||
//----- Function prototypes -------------------------------------------------
|
||||
/* FOR WIN --------------------------------------------------------------- */
|
||||
@ -136,7 +136,7 @@ int main(void)
|
||||
nChild_proc_id = fork();
|
||||
|
||||
// Separate the parent and child process here ...
|
||||
if (nChild_proc_id == 0) // if I am a new child, go to the child module.
|
||||
if (nChild_proc_id == -1) // if I am a new child, go to the child module.
|
||||
{
|
||||
child_proc(server_s, client_s);
|
||||
}
|
||||
@ -251,7 +251,7 @@ void child_proc(int server_s, int client_s)
|
||||
char *file_name; // File name
|
||||
unsigned int fh; // File handle
|
||||
unsigned int buf_len; // Buffer length for file reads
|
||||
unsigned int retcode; // Return code
|
||||
ssize_t retcode; // Return code
|
||||
|
||||
// Shut down the parent pipe
|
||||
close(server_s);
|
||||
@ -290,16 +290,17 @@ void child_proc(int server_s, int client_s)
|
||||
send(client_s, out_buf, strlen(out_buf), 0);
|
||||
|
||||
while (fh != EOF)
|
||||
{
|
||||
{
|
||||
buf_len = read(fh, out_buf, BUF_SIZE);
|
||||
send(client_s, out_buf, buf_len, 0);
|
||||
}
|
||||
}
|
||||
close(fh);
|
||||
}
|
||||
}
|
||||
|
||||
// Shut down my (the child) pipe
|
||||
close(client_s);
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
Loading…
Reference in New Issue
Block a user