Hi...
i am working on socket programming in c
so i define
Code:
int listenfd,connfd,portno,stringlen;
socklen_t clilen;
char buffer[1024];
char flgBuf[8];
uint8_t state;
struct sockaddr_in servaddr;
int n;
int sockfd,fd ; //for client socket
char fileName[128];
int CmpValue;
static void err_doit(int, int, const char *, va_list);
void str_fun(int Connfd);
void err_msg(const char *fmt, ...); /* to use this prototype in str_fun */
void str_fun(int Connfd)
{
if(connfd<0)
err_msg("Error,on Accept\n");
printf("waiting to provide file From the client IP:%s and port:%d\n\n",inet_ntoa(servaddr.sin_addr),ntohs(servaddr.sin_port ) );
strncpy(fileName,"hello",128);
printf("fileName is : %s \n",fileName);
for(;;)
{
//bzero(&buffer,sizeof(buffer));
//fd= open("abc.txt",O_RDONLY);
n=read(connfd,&buffer,sizeof(buffer));
printf("Now In Reading....\n");
printf("you want to download File : %s ",buffer);
CmpValue=strncmp(buffer,fileName,5);
if(CmpValue==0)
{
printf("File exist in server.\n");
state=1;
n=write(connfd,&buffer,sizeof(buffer));
}
else
{
printf("File not exist Honey.\n");
state=0;
printf("the state : %d \n",state);
}
so i want to assign the state value into char buffer without error or warning ,how to accomplish that ?????