Commit 3a2059c9 authored by Roshan Rabinarayan's avatar Roshan Rabinarayan

aaa

parent 2608a56a
......@@ -20,7 +20,7 @@ client library interfaces to do the actual operations.
#include "KVMessageFormat.h"
#include <arpa/inet.h>
#define MAX 80
#define PORT 8080
#define PORT 6969
#define SA struct sockaddr
struct message *request(char status,char* key,char* value)
{
......@@ -51,17 +51,6 @@ struct message *request(char status,char* key,char* value)
return requestMessage;
}
struct message* requestMessage;
void func(int sockfd)
{
char buff[MAX];
int n;
bzero(buff, sizeof(buff));
n = 0;
char message[256]="helloworld";
requestMessage = request('g',message,NULL);
send(sockfd , requestMessage , sizeof(struct message), 0 );
}
int main(int argc, char const *argv[])
{
......
......@@ -59,7 +59,7 @@ error. (Assume each character to be 1 byte in size)
*/
/*
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
......@@ -69,6 +69,7 @@ error. (Assume each character to be 1 byte in size)
#include <netinet/in.h>
#include <sys/epoll.h>
#include <string.h>
#include "KVMessageFormat.h"
#define MAX_EVENTS 10
void *worker(void *args) {
......@@ -76,7 +77,7 @@ void *worker(void *args) {
struct epoll_event ev, events[MAX_EVENTS];
int read_pipe, conn_sock, nfds, i;
int epollfd;
int *newfd;
int *newfd=malloc(sizeof(int));
read_pipe = ((int *) args)[0];
......@@ -102,14 +103,19 @@ void *worker(void *args) {
}
for ( i= 0; i < nfds; ++i ) {
if (events[i].data.fd == read_pipe) {
printf("Hola1!");
fflush(stdout);
read(read_pipe, newfd, sizeof(newfd));
printf("read %d", *newfd);
printf("Hola2!");
printf("\nread %d", *newfd);
if (epoll_ctl(epollfd, EPOLL_CTL_ADD, newfd, ) == -1) {
perror("epoll_ctl: read_pipe");
exit(EXIT_FAILURE);
}
fflush(stdout);
} else {
printf("im doing some work");
struct message *requestMessage= malloc(sizeof(struct message));
read( events[i].data.fd , requestMessage, sizeof(struct message));
printf("[Message Received from client]\n[[Status:%c]\n[Key:%s]\n[Value:%s]]",requestMessage->status,requestMessage->key,requestMessage->value);
}
}
}
......@@ -117,6 +123,7 @@ void *worker(void *args) {
}
int main (int argc, int argv) {
int i;
......@@ -156,19 +163,22 @@ int main (int argc, int argv) {
clilen = sizeof(cli_addr);
while(1) {
printf("Hola!");
fflush(stdout);
newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
if (newsockfd < 0)
perror("ERROR on accept");
write(pipes[next][1], &newsockfd, sizeof(newsockfd));
printf("main thread ka fd ka value: %d\n",newsockfd);
fflush(stdout);
next = (next+1) % pool_thread_size;
}
return 0;
}*/
}
/*
#include <stdio.h>
#include <netdb.h>
#include <netinet/in.h>
......@@ -179,7 +189,7 @@ int main (int argc, int argv) {
#include <sys/types.h>
#include "KVMessageFormat.h"
#define MAX 80
#define PORT 8080
#define PORT 6969
#define SA struct sockaddr
// Function designed for chat between client and server.
......@@ -256,3 +266,4 @@ int main(int argc, char const *argv[])
return 0;
}
*/
\ No newline at end of file
No preview for this file type
No preview for this file type
No preview for this file type
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