How to receive and send them properly?

this is my receiver:

Code:
	else if(command == 'f'){			
				//get name 
		
		
			
			char read;
			std::string collector;			//filename
			std::string sizellector;		//filename
			
			do{								//get filename
			
			recv(sock_CONNECTION,&read,1,0);
			
			if(read !='&')					//& is delimiter so no need to add
			collector += read;	
			
			}	while(read != '&');			//end at &
				
		
			
			read =0;//empty
			do{								
			recv(sock_CONNECTION,&read,1,0);	//get file type
			if(read !='&')						//& is delimiter so no need to add
			sizellector += read;				//
			
			}while(read != '&');				//end
						
	
			//collect and complete
			long size = atol(sizellector.c_str());	//convert string to int
	
			
			char * buffer = new char[size];			//alocate
			
			
			
			char ptr[1024];							//buffer
			int var = 0;					
			
			while(var <= size){						//
			recv(sock_CONNECTION,ptr,1024,0);		//receive
			strcat(buffer,ptr); 					//concatenate
			var=var+1024;							//increase
			}
			
			
			
			
			
			std::ofstream outfile (collector,std::ofstream::binary);
 			outfile.write (buffer,size);					//write	
			
			SetConsoleTextAttribute(hConsole, 2);
			std::cout<<" >Client:has sent a file named "<<collector<<" size is "<<sizellector<<std::endl;	//output
			SetConsoleTextAttribute(hConsole, csbiInfo.wAttributes);
		
		
			send(sock_CONNECTION, "File transfer is successful",28 ,NULL);
		
			delete [] buffer
			outfile.close();
		
		}
then this is my sender:

Code:
	send(sock,buffer,size,NULL);    // send 1400000 bytes of data in one go, is that possible?
Everything on the sender works fine except when sending the buffer itself(file).
Would it be possible to send in one go and let the receiver iterate? I am trying to send file to my tcp server but i can't seem to find the max values for the send and recv. Based from researching, they say that you have to loop until you get all of the bytes.