Hii all..
I am harika.. i have to develop a web server.. so, in that process.. i have a problem with the concept of using multiple threads.. actually, i have to excute GET cmd.. i am getting a problem in the 42nd line of my code.. i have highlighted it with bold and underline.. can any one help me out with this code??
Code:
#include<stdio.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<sys/types.h>
#include<pthread.h>
#include<stdlib.h>
void do_404(char *item, FILE *fp);
void process( char *rq, FILE *fp);
int main(int ac, char *av[])
{
char *buf;
int counter=0;
FILE *fp, *fpin, *fpout;
struct sockaddr_in addr;
addr.sin_family= AF_INET;
addr.sin_port=htons(7000);
char *request;
char hostname[256];
int adlen,fd,bd,new,ln;
pthread_t thread1, thread2;
fd=socket(AF_INET, SOCK_STREAM, 0);
bd=bind(fd, (struct sockaddr *)&addr, sizeof(addr));
//if(fd== -1)
//perror("Creation error");
//if(bd== -1)
//perror("socket binding failed");
sleep(4);
ln=listen(fd, 1);
adlen=sizeof(struct sockaddr_in);
while(1)
{
new=accept(fd, (struct sockaddr *)&addr, &adlen);
if(new<0)
perror("accepting error");
//else
//printf("Received ne client on socket=%d\n", new);
fpin=fdopen(fd, "r");
fpout=fdopen(fd, "w");
fgets(request, BUFSIZ, fpin);
while(fgets(buf, BUFSIZ, fp)!=NULL && strcmp(buf, "\r\n")!=0);
[tag]pthread_create(&thread1, NULL, &process(request, fpout), NULL);[/tag]
pthread_join(thread1, NULL);
printf("\n");
exit(0);
fclose(fpin);
fclose(fpout);
}
return 0;
}
void process(char *rq, FILE *fp)
{
char *item, *cmd, *arg;
if (scanf(rq, "%s%s", cmd, arg)!=2)
return;
if (strcmp(cmd, "GET")==0)
{
if( not_exist(item))
do_404(item, fp);
}
exit(0);
}
void do_404(char *item, FILE *fp)
{
fprintf(fp,"\r\n");
fflush(fp);
}