It is almost the same as mine yet mine hanged and yours dosnt ??

well thank you quzah i fixed it by doing minor adjustments like urs. Thanks to itsme as well

i have another wierd problem:

I am trying to send an http 200 response back to the client
Code:
int http_ok(char *buffer, FILE *local_file, int socket, char *time){
	printf("Sending ok\n");
	write(socket,"HTTP/1.0 200 OK\r\nServer: home\r\nDate: ???\r\n",strlen("HTTP/1.0 200 OK\r\nServer: home\r\nDate: ???\r\n"));
	char file[MAXDATASIZE];
	
	fread(file,1,MAXDATASIZE,local_file);
	file[MAXDATASIZE] = '\0';
	puts(file);
	write(socket,file,strlen(file));
	fflush(stdout);
}
here is what the output is from the terminal after a 2 tries, it vaires ...
Code:
host [~/a4]# ./forkclient localhost "GET ./forkserver.c HTTP/1.0"
I have written to the socket.
Recieved: HTTP/1.0 200 OK
Server: CSC209S/2004
Date: ???
004
host [~/a4]# ./forkclient localhost "GET ./forkserver.c HTTP/1.0"
I have written to the socket.
Recieved: HTTP/1.0 200 OK
Server: CSC209S/2004
Date: ???
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <strings.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/
What does 004 mean? if i try more it gives me the file i asked for but why does it output 004 on the first try SOMETIMES ?


thanks in advance