for(;;)
{
//printf("Ready to receive files.......\n");
n = 0;
len = clilen;
/* waiting for receive data */
memset(filename, '\0', sizeof(filename));
n = recvfrom(sockfd, filename, MAXLINE, 0, pcliaddr, &len);
filename[n-1] = '\0';
//printf("Client trying to get file %s \n\n",filename);
if (n <=1 )
{
//printf("File %s should be a real file.\n");
strcpy(mesg, "File should be a real file.\n");
sendto(sockfd, mesg, strlen(mesg), 0, pcliaddr, len);
continue;
}
/* sent data back to client */
fd=fopen((const char *)filename, "rw");
if (fd == NULL)
{
//printf("File %s does not exists.\n");
strcpy(mesg, "File does not exist.\n");
sendto(sockfd, mesg, strlen(mesg), 0, pcliaddr, len);
continue;
}