END_TEST START_TEST (test_conninvalid_connectinvalidparam) { void *conn = storage_connect(NULL, server_port); fail_unless(conn == NULL, "storage_connect with invalid param should fail."); fail_unless(errno == ERR_INVALID_PARAM, "storage_connect with invalid param not setting errno properly."); }
END_TEST START_TEST (test_wrongport) //Added 11 { void *conn = storage_connect(SERVERHOST, (server_port+1)); fail_unless(conn == NULL, "storage_connect with invalid param should fail."); fail_unless(errno != 8, "storage_connect with invalid param not setting errno properly."); }
END_TEST START_TEST (test_wronghost) //Added 10 { void *conn = storage_connect("wronghost", server_port); fail_unless(conn == NULL, "storage_connect with invalid param should fail."); fail_unless(errno != 0, "storage_connect with invalid param not setting errno properly."); }
END_TEST START_TEST (test_conn_connectnoserver) { sleep(1); // Give the OS enough time to kill previous process void *conn = storage_connect(SERVERHOST, server_port); fail_unless(conn == NULL, "Connecting to non-existent server should fail."); }
int libetpan_storage_connect(struct mailengine * engine, struct mailstorage * storage) { struct storage_ref_info * ref_info; ref_info = get_storage_ref_info(engine, storage); return storage_connect(ref_info); }
END_TEST START_TEST (test_conn_basic) { int serverpid = start_server(ONETABLE_CONF, NULL, "test_conn_basic.serverout"); fail_unless(serverpid > 0, "Server didn't run properly."); void *conn = storage_connect(SERVERHOST, server_port); fail_unless(conn != NULL, "Couldn't connect to server."); int status = storage_disconnect(conn); fail_unless(status == 0, "Error disconnecting from the server."); }
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."); }
/** * @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; }
END_TEST /* * Connection tests: * connect to and disconnect from server (pass) * connect to server without server running (fail) * connect to server with invalid hostname (fail) * disconnect from server with invalid params (fail) */ START_TEST (test_conn_basic) { int serverpid = start_server(ONETABLE_CONF, NULL, "test_conn_basic.serverout"); fail_unless(serverpid > 0, "Server didn't run properly."); void *conn = storage_connect(SERVERHOST, server_port); fail_unless(conn != NULL, "Couldn't connect to server."); int status = storage_disconnect(conn); fail_unless(status == 0, "Error disconnecting from the server."); }
/** * @brief Attempts to establish a connection with the server. * * Exits if the server connection fails due to any reason. * If already connected to a server, it asks the user if he/she wants to disconnect first. * @return Returns 0 on success, -1 otherwise. */ int client_connect() { char host[MAX_HOST_LEN], port[MAX_PORT_LEN]; int status; if(connected == true) { char c; bool read_success = false; while(read_success == false) { printf("Already connected to a server. Would you like to disconnect from it? (Y/N): "); char *l = fgets(input_buffer, sizeof input_buffer, stdin); if(l != input_buffer || (sscanf(input_buffer, " %1[YyNn] %s\n", &c, trash) != 1)) printf("Incorrect selection.\n"); else { read_success = true; if(c == 'Y' || c == 'y') { status = client_disconnect(); if(status == 0) status = client_connect(); } else status = 0; } } return status; } bool read_success = false; while(read_success == false) { printf("Please enter the hostname: "); char *l = fgets(input_buffer, sizeof input_buffer, stdin); if(l != input_buffer || (sscanf(input_buffer, "%s %s\n", host, trash) != 1)) printf("Please enter a valid hostname (no spaces).\n"); else read_success = true; } read_success = false; while(read_success == false) { printf("Please enter the port: "); char *l = fgets(input_buffer, sizeof input_buffer, stdin); if(l != input_buffer || (sscanf(input_buffer, "%[0-9] %s\n", port, trash) != 1)) printf("Invalid entry. Please enter a valid TCP port number (1024 - 65535).\n"); else read_success = true; } conn = storage_connect(host, atoi(port)); if(!conn) { printf("Cannot connect to server @ %s:%d. Error code: %d.\n", host, atoi(port), errno); status = -1; } else printf("Connection to %s:%s successful\n", host, port); return status; }
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; }
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; }
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; }
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; }
/** * @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; }