am trying to write a simple server program that prompts the user for an ISBN number or an author. it should check if the number is a valid number i.e if the number is 4 digits...it should also check if the user has entered a number or characters..it should then read the ISBN number(if it is wat the user has entered) and display the book details from a text file...the book details should be stored by the user....here is what i have since the code is very long am only going to put from binding.....thanx and i can post the whole code if it is necessary..
if (bind(sockfd, (struct sockaddr *) &serv_addr,
sizeof(serv_addr)) < 0)
error("ERROR on binding");
listen(sockfd,5);
clilen = sizeof(cli_addr);
newsockfd = accept(sockfd,
(struct sockaddr *) &cli_addr,
&clilen);
if (newsockfd < 0)
error("ERROR on accept");
bzero(buffer,256);
n = read(newsockfd,buffer,255);
if (n < 0) error("ERROR reading from socket");
if (buffer='ISBN')
{
int ISBN,fISBN[500];
int i=0,j=0;
char buffer[256];
int n, newsockfd;
FILE *fp = fopen(FILE_NAME, "r");
while(!feof(fp))
{
fscanf(fp,"%d", ISBN[i]); //loop thru the numbers into the array
i++;
}
if (i<4) error("ERROR:Incorrect ISBN number");
n = write(newsockfd,fISBN,18);
if (n<0) error("ERROR writing to socket");
}
else
{
printf("ERROR: Request does not exist\n");
printf("%s\n" , &buffer);
}
return 0;
}