int main()
{
	Tree *head = new Tree;
	head->value = -32999;
	head->left = NULL;
	head->right = NULL;
	head->prev = NULL;

	char c = 0;

	while (c != '0')
	{
		printf("\n	0 Exit\n	1 Add value to tree\n	2 Delete value from tree\n	3 Exist?\n	4 Print\n	");
		scanf("%c", &c);
		if (c == '\n')
			scanf("%c", &c);
		if (c == '1')
			addValue(head);
		if (c == '2')
			delValue(head);
		if (c == '3')
			existence(head);
		if (c == '4')
			printEl(head->left);
	}
	
	
	delTree(head->left);
	delete head;	
	return 0;
}
void create_child(int prev_socket_fd,struct sockaddr *client_address, request *client_req)
{
    pid_t pid=fork();
    if(pid<0)
        err("Error in creating child");
    else if(pid == 0)
    {
        close(prev_socket_fd);

        int socket_fd,addr_len=sizeof(struct sockaddr);
        struct sockaddr_in child_address;

        socket_fd=create_socket();
        fill_address(&child_address,0,NULL);
        bind_socket(&child_address,socket_fd);

        if (getsockname(socket_fd, (struct sockaddr *)&child_address, (socklen_t *)&addr_len) == -1)
            err("Error in resolving child address");

        printf("Child process created.Listening on port %d\n\n",ntohs(child_address.sin_port));

        ack_data *ack=(ack_data *)malloc(sizeof(ack_data));
        memset((void *)ack,0,sizeof(ack_data));

        if(!existence(client_req->filename))
        {
            perror("File does not exists");
            printf("File name is %s\n",client_req->filename );
            file_data *fdata=(file_data *)malloc(sizeof(file_data));
            fdata->data_block=-1;
            ssize_t nbytes=sendto(socket_fd,fdata,sizeof(file_data),0,client_address,(socklen_t )addr_len);

            exit(-1);
        }

        data_send(socket_fd,client_address,addr_len,client_req->filename);

        close(socket_fd);
        exit(0);
    }
}