- void recv_data(int sd, char **buffer) { 
-   
- 	int int_buf_size = 10; 
- 	char int_buf[int_buf_size]; 
- 	char *up_to_now = NULL; 
- 	int num_of_bytes_written = 0; 
-   
- 	int num_of_bytes_received = 0; 
- 	int done = 0; 
-   
- 	do { 
- 		num_of_bytes_received = recv(sd, int_buf, int_buf_size, 0); 
- 		assert(num_of_bytes_received!=-1); 
-   
- 		if (num_of_bytes_received == 0) { 
- 			done = 1; 
- 		} 
-   
- 		else { 
- 			printf("bytes received = %d \n"- ,num_of_bytes_received )- ; 
 
- 			up_to_now = realloc(up_to_now, num_of_bytes_received); 
- 			memcpy(&up_to_now[num_of_bytes_written], int_buf, num_of_bytes_received); 
- 			printf("bytes written = %d \n"- ,num_of_bytes_written )- ; 
 
- 			num_of_bytes_written = num_of_bytes_written + num_of_bytes_received; 
- 			printf("bytes written = %d \n"- ,num_of_bytes_written )- ; 
 
-   
- 		} 
- 	} while (!done); 
-   
-   
- 	printf("bytes written final = %d \n"- ,num_of_bytes_written )- ; 
 
-   
- 	*buffer = malloc(num_of_bytes_written); 
- 	memcpy(*buffer,up_to_now,num_of_bytes_written); 
-   
- }