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];
FILE *infile;
 while (1) 
		if (testfile == INVALID_HANDLE_VALUE) {
		infile = fopen(filename,"a+b");
		if (infile == NULL) {
		err = 1;
		while (err != 0) {
			err = recv(Client, cbuffer, sizeof(cbuffer), 0);
			received = received + err;
			received2 =  htonl(received);
			send(Client,(char *)&received2 , 4, 0);

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.