Hi.

I`m working on an application which reads a file from the disk, and sends it`s content over socket to a browser. The problem is that when the application starts sending the data, the browser shows the waiting for data icon for a while, and then stops with the no data received message. The function is the following:

Code:
void stream(int clientDescriptor, char *path)
{
	FILE *fp 			= NULL;
	char *fileContent 	        = NULL;
	long fileSize		= 0;
	int i				= 0;

	fp 		= fs_openFile(path, "rb");
	fileSize	= fs_getFileSize(fp);
	fileContent	= fs_getFileByPointer(fp);

	for (i=0;i<fileSize;i++)
	{
printf("%c",fileContent[i]);
		write(clientDescriptor, fileContent[i], 1);
	}
}
The printf("%c",fileContent[i]); part is working fine, it prints the whole content of the file to the screen, but the same fileContent[i] doesn`t arrive to the browser, or maybe the browser waits for some extra character...

I know there are many examples on the internet, but none of those worked for me. Maybe you can help me.


Thank you.