예제 #1
0
파일: main.c 프로젝트: MattMarji/storage
END_TEST



/* Added
 * Two client instance get/set pass tests:
 *      set/get basic table/key/value names from one table.
 *      set/get extended table/key/value names from one table.
 *      set/get extended table/key/value names from two tables.
 */

START_TEST (test_restartclient_onetable)
{
        struct storage_record r;

        // Start and connect to the server.
        int serverpid = 0;
        void *conn = start_connect(ONETABLE_CONF, "test_restartclient_onetable.serverout", &serverpid);
        fail_unless(conn != NULL, "Couldn't start or connect to server.");

        // Set a key/value.
        strncpy(r.value, VALUE, sizeof r.value);
        int status = storage_set(TABLE, KEY, &r, conn);
        fail_unless(status == 0, "Error setting a key/value pair.");

        // Disconnect from the server.
        status = storage_disconnect(conn);
        //fail_unless(status == 0, "Error disconnecting from the server.");

        // Reconnect to the server
	conn = storage_connect(SERVERHOST, server_port);
        fail_unless(conn != NULL, "Couldn't connect to server.");
	
	// Authenticate with the server.
	status = storage_auth(SERVERUSERNAME, SERVERPASSWORD, conn);
	fail_unless(status == 0, "Authentication failed.");

        // Get a value.
        strncpy(r.value, "", sizeof r.value);
        status = storage_get(TABLE, KEY, &r, conn);
        fail_unless(status == 0, "Error getting a value.");
        fail_unless(strcmp(r.value, VALUE) == 0, "Got wrong value.");

        // Disconnect from the server.
        status = storage_disconnect(conn);
        //fail_unless(status == 0, "Error disconnecting from the server.");
}
예제 #2
0
/**
 * @brief Attempts to authenticate the user with the server.
 *
 * Closes server connection and exits if the user fails to authenticate.
 * @return Returns 0 on success, -1 otherwise.
 */
int client_auth()
{
    
    char username[MAX_USERNAME_LEN] = {0}, password[MAX_ENC_PASSWORD_LEN] = {0};
    
    bool read_success = false;
    while(read_success == false)
    {
        printf("Please enter the username: "******"%s %s", username, trash) != 1))
            printf("Please enter a valid username (no spaces).\n");
        else
            read_success = true;
    }
    
    read_success = false;
    while(read_success == false)
    {
        printf("Please enter the password: "******"%s %s", password, trash) != 1))
            printf("Please enter a valid password (no spaces).\n");
        else
            read_success = true;
    }
    
    int i;
    char pass_asterik[strlen(password) + 1];
    for(i = 0; i < strlen(password); i++)
        pass_asterik[i] = '*';
    pass_asterik[i] = 0;
    
    int status = storage_auth(username, password, conn);
    if(status != 0)
    {
        printf("storage_auth failed with username '%s' and password '%s'. " \
               "Error code: %d.\n", username, pass_asterik, errno);
        storage_disconnect(conn);
    }
    else
        printf("storage_auth: successful.\nWelcome %s!\n", username);
    
    return status;
}
예제 #3
0
/**
 * @brief Start the server, and connect to it.
 * @return A connection to the server if successful.
 */
void* start_connect(char *config_file, char *serverout_file, int *serverpid)
{
	// Start the server.
	int pid = start_server(config_file, NULL, serverout_file);
	fail_unless(pid > 0, "Server didn't run properly.");
	if (serverpid != NULL)
		*serverpid = pid;

	// Connect to the server.
	void *conn = storage_connect(SERVERHOST, server_port);
	fail_unless(conn != NULL, "Couldn't connect to server.");

        // Authenticate with the server.
	int status = storage_auth(SERVERUSERNAME, SERVERPASSWORD, conn);
	fail_unless(status == 0, "Authentication failed.");

	return conn;
}
예제 #4
0
int main(){
    void *conn = storage_connect(HOSTNAME , PORT);
    if(conn == NULL) {
        printf("Error starting the server, please make sure the socket is not being used.\n");
        printf("Notice that the parameters inside the *.conf file should be as follows:\n");
        printf("Hostname: %s\n",HOSTNAME);
        printf("Port: %d\n",PORT);
        return -1;
    }
    int status = storage_auth(ADMIN , DEC_PASSWORD , conn);
    if (status != 0) {
        printf("Error authenticating the server, make sure that the parameters inside the *.conf file are as follows:\n");
        printf("Username: %s\n",ADMIN);
        printf("Decrypted Password: %s\n",DEC_PASSWORD);
        return -1;
    }



    printf("\n\nTes 1: ");
    struct storage_record record;
    strcpy(record.value,VALUE1);                                     //test case 1 for get
    status = storage_set(TABLE1, KEY1, &record, conn);
    if (status != 0) {
        printf("The test failed, not set value.");
    }
    else {
        status = storage_get(TABLE1, KEY1, &record, conn);
        if (status != 0) {
            printf("The test failed.");
        }
        else if ((strcmp(record.value, VALUE1) == 0)) {
            printf("Test is ok.");
        }
        else {
            printf("The test failed, value retrieved not the same that should be.");
        }
    }


    printf("\n\nTest 2: ");
    strcpy(record.value,VALUE2);                                      //test case 2 for get
    status = storage_set(TABLE2, KEY2, &record, conn);
    if (status != 0) {
        printf("The test failed, not set value.");
    }
    else {
        status = storage_get(TABLE2, KEY2, &record, conn);
        if (status != 0) {
            printf("The test failed.");
        }
        else if ((strcmp(record.value, VALUE2) == 0)) {
            printf("Test is ok.");
        }
        else {
            printf("The test failed, value retrieved not the same that should be.");
        }
    }


    printf("\n\nTest 3: ");              ///Test case 3
	status = storage_get(INV_TABLE, KEY1 , &record , conn);
	if(status != 0) {
        if(errno == 1)
    		printf("The test is ok.");
        else
            printf("The test failed, errno not set correctly.");
	}
	else {
		printf("The test failed, should have failed to get the value.");
    }





    printf("\n\nTest 4: ");                      ///Test case 4
 	status = storage_get(TABLE2, INV_KEY , &record , conn);
	if(status != 0) {
        if(errno == 1)
    		printf("The test is ok.");
        else
            printf("The test failed, errno not set correctly.");
	}
	else {
		printf("The test failed, should have failed to get the value.");
       }



    printf("\n\nTest 5: ");
    status = storage_get(TABLE2, KEY3 , &record , conn);    ///TEST 5
    if (status != 0){
        if (errno == 6)
            printf("The test is ok.\n");
        else
            printf("The test failed, errno not set correctly.");
    }
    else {
        printf("The test failed, should have failed to get.\n");
    }



    return 0;
}
예제 #5
0
int main(){
    void *conn = storage_connect(HOSTNAME , PORT);
    if(conn == NULL) {
        printf("Error starting the server, please make sure the socket is not being used.\n");
        printf("Notice that the parameters inside the *.conf file should be as follows:\n");
        printf("Hostname: %s\n",HOSTNAME);
        printf("Port: %d\n",PORT);
        return -1;
    }
    int status = storage_auth(ADMIN , DEC_PASSWORD , conn);
    if (status != 0) {
        printf("Error authenticating the server, make sure that the parameters inside the *.conf file are as follows:\n");
        printf("Username: %s\n",ADMIN);
        printf("Decrypted Password: %s\n",DEC_PASSWORD);
        return -1;
    }

    char *keys[100];
    struct storage_record record;                                     //test case 1 for set
    strcpy(record.value,VALUE1);
    status = storage_set(TABLE1, KEY1, &record, conn);
    if (status != 0) {
        printf("The test failed to add a key.");
        return -1;
    }
    else {
        strcpy(record.value,VALUE2);
        status = storage_set(TABLE2, KEY2, &record, conn);
        if (status != 0) {
            printf("The test failed to add a key.");
            return -1;
        }
    }


    printf("\n\nTest 1: ");             ///Test 1
    status = storage_query(TABLE1 , "invalid query" , keys , 1 , conn );
    if(status != -1) {
        printf("test failed, query should return an error.");
    }
    else {
        if (errno != 1){
            printf("test failed, errno not being set correctly.");
        }
        else
            printf("test is ok.");
    }




    printf("\n\nTest 2: ");         ///Test 2
    status = storage_query(INV_TABLE , "col1 = string" , keys , 1 , conn );
    if(status != -1) {
        printf("test failed, query should return an error.");
    }
    else {
        if (errno != 1){
            printf("test failed, errno not being set correctly.");
        }
        else
            printf("test is ok.");
    }


    printf("\n\nTest 3: ");                 ///Test 3
    status = storage_query(TABLE1 , "col1 > string" , keys , 1 , conn );
    if(status != -1) {
        printf("test failed, query should return an error.");
    }
    else {
        if (errno != 1){
            printf("test failed, errno not being set correctly.");
        }
        else
            printf("test is ok.");
    }



    printf("\n\nTest 4: ");         ///Test 4
    status = storage_query(TABLE2 , "col2 = string" , keys , 1 , conn );
    if(status != -1) {
        printf("test failed, query should return an error.");
    }
    else {
        if (errno != 1){
            printf("test failed, errno not being set correctly.");
        }
        else
            printf("test is ok.");
    }



    printf("\n\nTest 5: ");     ///Test 5
    status = storage_query(TABLE2 , "col2 > 0" , keys , 1 , conn );
    if(status == -1) {
        printf("test failed, query failed.");
    }
    else {
        if (status != 1){
            printf("test failed, number of keys returned not correct.");
        }
        else {
            if(strcmp(keys[1],"") == 0) {
                if(strcmp(keys[0],KEY2) == 0)
                    printf("test is ok.");
                else
                    printf("test failed, key retrieved isn't as expected.");
            }
            else
                printf("test failed, keys returned are different than expected.");
        }
    }

    printf("\n\n");

    return 0;
}
예제 #6
0
int main(int argc, char *argv[])
{
	// initial variables used throughout all of the commands
	int i;
	int SERVERPORT;
	char SERVERHOST[MAX_HOST_LEN], SERVERUSERNAME[MAX_USERNAME_LEN], SERVERPASSWORD[MAX_ENC_PASSWORD_LEN], SERVERPORTstr[MAX_PORT_LEN];
	char TABLE[MAX_TABLE_LEN], KEY[MAX_KEY_LEN];
	char **key = malloc(sizeof(char**)*800);
	char PREDICATES_1[500];
	char PREDICATES[500];
	void *conn = NULL;
	int status;
	struct storage_record r;
	int authenticated = 0;

	do{
		printmenu(&i); // function to prompt the user for the menu and read in and update the variable i

		if(i == 0){// Connect to server
			if(conn != NULL)
				printf("You are already connected. Please choose another option.\n\n");
			else
			{
				conn = storage_connect("localhost",2222);
				if(!conn)
				{
					printf("Cannot connect to server @ %s:%d. Error code: %d.\n", SERVERHOST, SERVERPORT, errno);
					//return -1;
				}
				else printf("\nUser conncected with the server\n");
				status = storage_auth("admin", "dog4sale", conn);
				if(status != 0)
				{
					printf("storage_auth failed with username '%s' and password '%s'. " \
					"Error code: %d, status: %d\n", SERVERUSERNAME, SERVERPASSWORD, errno, status);
					//storage_disconnect(conn);
					//return status;
				}
				else{
					authenticated = 1;
					printf("\nUser authenticated with the server\n");
				}
			}
		}
		if(i == 1)
		{// Connect to server
			if(conn != NULL)
				printf("You are already connected. Please choose another option.\n\n");
			else
			{
				printf("Enter the Server Host\n");
				fgets(SERVERHOST, MAX_HOST_LEN, stdin);
				sscanf(SERVERHOST, "%s", SERVERHOST);
				printf("Enter the Server Port\n");
				fgets(SERVERPORTstr, MAX_PORT_LEN, stdin);
				sscanf(SERVERPORTstr, "%d", &SERVERPORT);
				conn = storage_connect(SERVERHOST, SERVERPORT);
				if(!conn)
				{
					printf("Cannot connect to server @ %s:%d. Error code: %d.\n", SERVERHOST, SERVERPORT, errno);
					//return -1;
				}
				else printf("\nUser connected with the server\n");
			}
		}

		else if(i == 2)
		{// Authenticate the client.
			if(conn == NULL)
				printf("You are not connected yet. Please connect to the server first.\n\n");
			//else if(authenticated == 1)
				//printf("You are already authenticated. Please choose another option.\n\n");
			else
			{
				printf("Enter the UserName Host\n");
				fgets(SERVERUSERNAME, MAX_USERNAME_LEN, stdin);
				sscanf(SERVERUSERNAME, "%s", SERVERUSERNAME);
				printf("Enter the Password Host\n");
				fgets(SERVERPASSWORD, MAX_ENC_PASSWORD_LEN, stdin);
				sscanf(SERVERPASSWORD, "%s", SERVERPASSWORD);
				status = storage_auth(SERVERUSERNAME, SERVERPASSWORD, conn);
				if(status != 0)
				{
					printf("storage_auth failed with username '%s' and password '%s'. " \
							"Error code: %d, status: %d\n", SERVERUSERNAME, SERVERPASSWORD, errno, status);
				}
				else{
					authenticated = 1;
					printf("\nUser authenticated with the server\n");
				}
			}
		}

		else if(i == 3)
		{// SET command
			if(conn == NULL)
				printf("You are not connected yet. Please connect to the server first.\n\n");
			else
			{
				printf("Please enter the Table\n");
				fgets(TABLE, MAX_TABLE_LEN, stdin);
				sscanf(TABLE, "%s", TABLE);
				printf("Please enter the Key\n");
				fgets(KEY, MAX_KEY_LEN, stdin);
				sscanf(KEY, "%s", KEY);
				printf("Please Enter the record that you wish to store\n");
				fgets(r.value, MAX_VALUE_LEN, stdin);
				r.value[strlen(r.value)-1] = '\0';
				//strncpy(r.value, value, sizeof value);

				//This is for measuring the server processing time
				//remember when the process started
				clock_t t;
				t=clock();
				//issue set call to DATABASE with TABLE, KEY and r.value
				if(!strcmp(r.value,"null")){
					status = storage_set(TABLE,KEY,NULL,conn);
				}
				if(strcmp(r.value,"null"))
				status = storage_set(TABLE, KEY, &r, conn);
				//find how long it took to perform the GET operation
				//current time minus the time when the operation started
				t=clock()-t;

				if(status != 0)
				{
					printf("storage_set failed. Error code: %d.\n", errno);
				}
				else
					printf("storage_set: successful.\n");
			}
		}

		else if(i == 4)
		{// GET command
			if(conn == NULL)
				printf("You are not connected yet. Please connect to the server first.\n\n");
			//else if(authenticated == 0)
				//printf("You are not authenticated yet. Please authenticate first.\n\n");
			else
			{
				printf("Please enter the Table\n");
				fgets(TABLE, MAX_TABLE_LEN, stdin);
				sscanf(TABLE, "%s", TABLE);
				printf("Please enter the Key\n");
				fgets(KEY, MAX_KEY_LEN, stdin);
				sscanf(KEY, "%s", KEY);
				status = storage_get(TABLE, KEY, &r, conn);
				if(status != 0)
				{
					printf("storage_get failed. Error code: %d.\n", errno);
					storage_disconnect(conn);
					return status;
				}
				else
					printf("storage_get: the value returned for key '%s' is '%s'.\n", KEY, r.value);
			}
		}

		else if(i == 5)
		{// QUERY command
			if(conn == NULL)
				printf("You are not connected yet. Please connect to the server first.\n\n");
			else
			{
				printf("Please enter the Table\n");
				fgets(TABLE, MAX_TABLE_LEN, stdin);
				sscanf(TABLE, "%s", TABLE);

				printf("Please enter the Predicates\n");
				fgets(PREDICATES_1, 500, stdin);
				sscanf(PREDICATES_1, "%[^'\n]",PREDICATES);
				// (const char *table, const char *predicates, char **keys, const int max_keys, void *conn)
				status = storage_query(TABLE, PREDICATES, key, &r, conn);
				//int foundkeys = storage_query(INTTABLE, "col<-1", test_keys, MAX_RECORDS_PER_TABLE, test_conn);
				printf("status/number of keys: %d\n",status);
				if(status == -1)
				{
					printf("storage_query failed. Error code: %d.\n", errno);
					storage_disconnect(conn);
					return status;
				}
				else {
					int p = 0;

					int i = 0;

					while (key[i] != NULL){
						printf("key: '%s'\n", key[i]);
						i++;

					}
				}
			}
		}


		else if(i==6)
		{// Disconnect from server
			status = storage_disconnect(conn);
			if(status != 0)
			{
				printf("storage_disconnect failed. Error code: %d.\n", errno);
				return status;
			}
			else
			{
				conn = NULL;
				authenticated = 0;
				printf("You are now disconnected\n");
			}
		}
		else if (i==8){
			// import the census into the data base
			if(conn == NULL)
				printf("You are not connected yet. Please connect to the server first.\n\n");
			 FILE* fp;
			fp=fopen("census", "r");               //open the file for reading only
   			if(fp == NULL)
   			 printf("Error opening file");
  			 else
   			{
				int loop;
       				//populate the table with all the data in the data file (city + its population)
				do {
					char name[100];
					char value[MAX_VALUE_LEN];
					char line[100];
       					char *l = fgets(line, sizeof line, fp);
					if (!feof(fp)){
						sscanf(l, "%s %s", name, value);
						printf("name: %s , value: %s \n", name, value);
						strcpy(r.value,value);
						status = storage_set("census", name, &r, conn);
						if(status != 0)
						{
							printf("storage_set failed. Error code: %d.\n", errno);
						}			
					}
					
				   }
       				 while(!feof(fp));     //read the first line (city)	
   			}
		}

	} while (i!=7); // if i is 6, we want to exit from client

	// Exit
	return 0;
}
예제 #7
0
파일: tester.c 프로젝트: charliehorse55/esb
const char* testClient(void* parameters)
{
    struct workerTask* worker = (struct workerTask*)parameters;
    
    uint16_t randContext[3];
    for(int i = 0; i < 3; i++)
    {
        randContext[i] = time(NULL) ^ worker->workerID;
    }
    
    if(!worker->conn)
    {
        //spread the load from new connections so the server won't be overloaded
        usleep(erand48(randContext) * 1000 + 1000*worker->connOpenDelay);
        
        worker->conn = storage_connect(worker->hostname, worker->port);
        if(!worker->conn)
        {
            printf("storage_connect failed\n");
            return ece297strerror(errno);
        }
        
        int result = storage_auth(worker->username, worker->password, worker->conn);
        if(result == -1)
        {
            printf("storage_auth failed\n");
            storage_disconnect(worker->conn);
            worker->conn = NULL;
            return ece297strerror(errno);
        }
    }
    
    uint64_t loopCount = worker->numKeys;
    if(worker->type == kClientRunWorkload)
    {
        loopCount = worker->count;
    }
    
    uint64_t period = 0;
    
    //0 throughput = no limit
    if(worker->throughput)
    {
        period = (1/worker->throughput) * 1000000;
        
        //start at a random time
        usleep(erand48(randContext) * period);
    }
    struct timeval next;
    gettimeofday(&next, NULL);
    
    for(uint64_t i = 0; i < loopCount; i++)
    {
        if(worker->throughput)
        {
            int64_t timeRemaining = -uSElapsed(&next);
            if(timeRemaining > 0)
            {
                usleep((uint32_t)timeRemaining);
            }
            uint64_t newTime = next.tv_usec + period;
            next.tv_sec += newTime / 1000000;
            next.tv_usec = newTime % 1000000;
        }
        switch (worker->type)
        {
            case kClientAddKeys:
            {
                char keyBuf[20]; //as per ECE297 spec
				stringGen(worker->startingKey + i, worker->keySecret, keyBuf, sizeof(keyBuf));
                
                struct storage_record record;
                memset(&record.metadata, 0, sizeof(record.metadata));
                
				stringGen(worker->startingKey + i, worker->valueSecret, record.value, sizeof(record.value));
                                				
                struct timeval start;
                gettimeofday(&start, NULL);
                if(storage_set(worker->table, keyBuf, &record, worker->conn) == -1)
                {
                    printf("storage_set failed\n");
                    return ece297strerror(errno);
                }
                recordLatency(timeElapsed(&start), worker->latencyResults);
                break;
            }
                                
            case kClientRunWorkload:
            {
				//WATCH the floating point promotion - it must be cast to a uint64_t BEFORE adding worker->startingKey
                uint64_t keyIndex = ((uint64_t)(erand48(randContext) * worker->numKeys)) + worker->startingKey;
                
                char keyBuf[20]; //as per ECE297 spec
				stringGen(keyIndex, worker->keySecret, keyBuf, sizeof(keyBuf));
                char expectedValue[1024];
				stringGen(keyIndex, worker->valueSecret, expectedValue, sizeof(expectedValue));
				
                struct timeval start;
                gettimeofday(&start, NULL);
                struct storage_record rec;
                if(storage_get(worker->table, keyBuf, &rec, worker->conn) == -1)
                {
                    printf("storage_get failed (key index = %u)\n", keyIndex);
                    return ece297strerror(errno);
                }
                if(strcmp(rec.value, expectedValue)) {
                	return "Server returned incorrect key";
                }
				
                recordLatency(timeElapsed(&start), worker->latencyResults);
            }
        }
    }
    return NULL;
}
예제 #8
0
/**
 * @brief Start a client to interact with the storage server.
 *
 * If connect is successful, the client performs a storage_set/get() on
 * TABLE and KEY and outputs the results on stdout. Finally, it exists
 * after disconnecting from the server.
 */
int main(int argc, char *argv[])
{
    if(LOGGING == 1)
        ClientFile = stdout;
    else if(LOGGING == 2)
    {
        time_t Time = time(NULL);
        struct tm *currentTime = localtime(&Time);
        char ClientFileName[MAX_CONFIG_LINE_LEN];
        int day = currentTime->tm_mday;
        int month = currentTime->tm_mon + 1; // Month is 0 - 11, add 1 to get a jan-dec 1-12 concept
        int year = currentTime->tm_year + 1900;
        int hour = currentTime->tm_hour;
        int minute = currentTime->tm_min;
        int second = currentTime->tm_sec;
        snprintf(ClientFileName, sizeof ClientFileName, "Client-%d-%02d-%02d-%02d-%02d-%02d.log",year,month,day,hour,minute,second);//making a string
        ClientFile = fopen(ClientFileName,"a");
    }
        int selection = 0, port, status;
        char hostname[MAX_HOST_LEN+1], username[MAX_USERNAME_LEN], password[MAX_ENC_PASSWORD_LEN],table[MAX_TABLE_LEN],key[MAX_KEY_LEN], strc[MAX_CONFIG_LINE_LEN];
        struct storage_record r;
        void *conn;
    // Client Interaction with the server
    while(selection!=6)
    {
        printf("> ----------------------\n");
        printf("> 1) Connect\n");
        printf("> 2) Authenticate\n");
        printf("> 3) Get\n");
        printf("> 4) Set\n");
        printf("> 5) Disconnect\n");
        printf("> 6) Exit\n");
        printf("> ----------------------\n");
        printf("> Please enter your selection: ");
        scanf("%d",&selection);
        
        // Connect to server
        if(selection == 1)
        {
            printf("> Please input the hostname: ");
            scanf("%s",hostname);
            printf("> Please input the port: ");
            scanf("%d",&port);
            conn = storage_connect(hostname, port);
            if(!conn)
            {
                snprintf(strc, sizeof strc, "> Cannot connect to server @ %s:%d. Error code: %d.\n",hostname, port, errno);
                printf("%s",strc);
                logger(ClientFile,"a");
                return -1;
            }
            snprintf(strc, sizeof strc, "> Connecting to %s:%d ...\n",hostname,port);
            printf("%s",strc);
            logger(ClientFile,"a");
        }
        
        // Authenticate the client.
        else if (selection == 2)
        {
            printf("> Please enter your username: "******"%s",username);
            printf("> Please enter your password: "******"%s",password);
            status = storage_auth(username, password, conn);
            if(status != 0)
            {
                snprintf(strc, sizeof strc, "> storage_auth failed with username '%s' and password '%s'. " \
                       "Error code: %d.\n", username, password, errno);
                printf("%s",strc);
                logger(ClientFile,strc);
                storage_disconnect(conn);
                return status;
            }
            snprintf(strc, sizeof strc, "> storage_auth: successful.\n");
            printf("%s",strc);
            logger(ClientFile,strc);
        }
        
        // Issue storage_get
        else if (selection == 3)
        {
            printf("> Please enter table name: ");
            scanf("%s",table);
            printf("> Please enter key: ");
            scanf("%s",key);
            status = storage_get(table, key, &r, conn);
            if(status != 0)
            {
                snprintf(strc, sizeof strc, "> storage_get failed. Error code: %d.\n", errno);
                printf("%s",strc);
                logger(ClientFile,strc);
                storage_disconnect(conn);
                return status;
            }
            snprintf(strc, sizeof strc, "> storage_get: the value returned for key '%s' is '%s'.\n",
                   key, r.value);
            printf("%s",strc);
            logger(ClientFile,strc);
        }
        // Issue storage_set
        else if(selection == 4)
        {
            printf("> Please enter table name: ");
            scanf("%s",table);
            printf("> Please enter key: ");
            scanf("%s",key);
            
            strncpy(r.value, "some_value", sizeof r.value);
            status = storage_set(table, key, &r, conn);
            if(status != 0)
            {
                snprintf(strc, sizeof strc, "> storage_set failed. Error code: %d.\n", errno);
                printf("%s",strc);
                logger(ClientFile,strc);
                storage_disconnect(conn);
                return status;
            }
            snprintf(strc, sizeof strc, "> storage_set: successful.\n");
            printf("%s",strc);
            logger(ClientFile,strc);
        }
        // Disconnect from server
        else if (selection == 5)
        {
            status = storage_disconnect(conn);
            if(status != 0)
            {
                snprintf(strc, sizeof strc, "> storage_disconnect failed. Error code: %d.\n", errno);
                printf("%s",strc);
                logger(ClientFile,strc);
                return status;
            }
            snprintf(strc, sizeof strc, "> Disconnecting from %s:%d ...\n",hostname,port);
            printf("%s",strc);
            logger(ClientFile,strc);
        }
        //Exit
        else if (selection == 6)
            printf("> Exiting server...\n");
        else
            printf("> Enter your selection again\n");
        
    }
    fclose(ClientFile);
    return 0;
}