Commit 3aca97f5 authored by Saikumar's avatar Saikumar

modified by sai

parent acf37be8
......@@ -25,4 +25,4 @@ server:all
./server_s
client:
./client_c 127.1.1.3 20000
./client_c 127.1.1.2 20000
......@@ -4,7 +4,7 @@
#include <unordered_map>
#include <string>
#include <cstdlib>
#include "cs_thread.h"
// #include "cs_thread.h"
#include "cache.h"
#include "storage.h"
using namespace std;
......@@ -112,6 +112,7 @@ string GET(string key) {
// //uncLock
// }
// return value;
return "ERROR";
}
return ans;
......@@ -119,7 +120,7 @@ string GET(string key) {
}
string PUT(string key, string value) {
cout << "PUT started" << endl;
// cout << "PUT started" << endl;
pthread_mutex_lock(&cLock);
string ans = search(key);
if(ans == "") {
......
......@@ -83,7 +83,7 @@ void sendToServer(int sockfd) {
}
int GET(char* key, char *request) {
printf("GET called!\n");
// printf("GET called!\n");
// char request[513];
memset(request, '0', 513);
request[0] = '1';
......@@ -93,19 +93,19 @@ int GET(char* key, char *request) {
}
int PUT(char* key, char* value, char *request) {
printf("PUT called!\n");
// printf("PUT called!\n");
// char request[513];
memset(request, '0', 513);
request[0] = '2';
// memcpy(request+1, key, strlen(key));
memcpy(request+257-strlen(key), key, strlen(key));
memcpy(request+513-strlen(value), value, strlen(value));
printf("key at index: %ld\n", 257-strlen(key));
printf("value at index: %ld\n", 513-strlen(value));
// printf("key at index: %ld\n", 257-strlen(key));
// printf("value at index: %ld\n", 513-strlen(value));
}
int DELETE(char* key, char *request) {
// char request[513];
printf("DELETE called!\n");
// printf("DELETE called!\n");
memset(request, '0', 513);
request[0] = '3';
// memcpy(request+1, key, strlen(key));
......
......@@ -8,7 +8,7 @@
#include <pthread.h>
#include <stdlib.h>
#include "cache.h"
#include "cs_thread.h"
// #include "cs_thread.h"
using namespace std;
// struct lock cLock;
......@@ -52,7 +52,7 @@ void *respondToClient(void *args) {
string key_string, value_string;
switch(todo) {
case '1':
printf("GET recvd\n");
// printf("GET recvd\n");
// printf("Key: %s\n", key);
// j = search(key);
// printf("j=%d\n", j);
......@@ -67,7 +67,7 @@ void *respondToClient(void *args) {
write(clientFd, converted_output, output.length());
break;
case '2':
printf("PUT recvd\n");
// printf("PUT recvd\n");
// printf("Key: %s\n", key);
// printf("Value: %s\n", value);
key_string = key;
......@@ -80,7 +80,7 @@ void *respondToClient(void *args) {
write(clientFd, converted_output, output.length());
break;
case '3':
printf("DELETE recvd\n");
// printf("DELETE recvd\n");
// printf("Key: %s\n", key);
key_string = key;
// pthread_mutex_lock(&cLock);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment