bl4ckch3rry 0 Newbie Poster

Hi, i searched around and couldn't find any examples on what i'm looking for.. Im a newbie when it comes to Winsock (C++) and im not sure what im doing wrong, if you could just point me in the right direction or provide some source code that'd be very helpfull, thanks.
I'm creating a simple web server type application and i want to send a file to the client (web browser) when they connect, i have everything working except the send file part.. the code below is what i was using, i know it's full of errors.. but i'm not sure where to go with it becuase im not familiar with winsock or how to create the file and send each individual part..

DWORD err;
char cbuffer[4096]; 
int received = 0;
unsigned long received2;
char filename[MAX_PATH];
sprintf(filename,"C:\\ok.txt");
FILE *infile;
 while (1) 
	{
 HANDLE testfile =  CreateFile(filename,GENERIC_WRITE,FILE_SHARE_READ,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
		if (testfile == INVALID_HANDLE_VALUE) {
			break;
		}
		CloseHandle(testfile);
		infile = fopen(filename,"a+b");
		if (infile == NULL) {
			break;
		}
		err = 1;
		while (err != 0) {
			memset(cbuffer,0,sizeof(cbuffer));
			err = recv(Client, cbuffer, sizeof(cbuffer), 0);
			fwrite(cbuffer,1,err,infile);
			received = received + err;
			received2 =  htonl(received);
			send(Client,(char *)&received2 , 4, 0);
		}
		break;
	}

If you could just point me in the right direction (links?) or give me some source code it would be much appreciated.. thanks