hi
I am writing a client-server program and the functions I've written on the server are never executed. even something as easy as typing hello does not. is there something to be taken into account to use functions?
I appreciate any information
Without more information it is hard to give any sort of a useful answer. Can you show us your code?
This is the code of my program
void getFiles(int siz, char *root, char *infor)
{
DIR *d;
struct dirent *ent;
struct stat inode;
if ((d = opendir (root)) != NULL)
{
chdir (root);
while(ent=readdir(d))
{
lstat (ent->d_name, &inode);
if (S_ISDIR(inode.st_mode) && strcmp(ent->d_name, ".") && strcmp(ent->d_name, ".."))
{
getFiles(siz, ent->d_name, infor);
chdir("..");
} //if
} //while
} //if
}
int main()
{
char root[256];
char buffer[125];
struct sockaddr_in cli, serv;
int sfd;
char result[1024];
char infor[1024];
char size[10];
int siz;
int siz_cli = sizeof(cli);
int siz_serv = sizeof(serv);
//////////////////////////////////////////////
serv.sin_family = AF_INET;
serv.sin_port = 5556;
serv.sin_addr.s_addr = inet_addr("127.0.0.1");
/////////////////////////////////////////////
sfd = socket(AF_INET, SOCK_DGRAM, 0);
int vbleBind = bind(sfd, (struct sockaddr*) &serv, siz_serv);
if(vbleBind == -1)
{
perror("error \n");
return 0;
}
else
{
while( 1 )
{
if( (recvfrom(sfd, size, 10, 0,(struct sockaddr *) &cli, &siz_cli) ) < 0)
{
perror("error \n");
return 0;
}
else
{
siz=atoi(size);
system("pwd>root");
int fd=open("root", O_RDWR, 644);
while( read(fd, buffer, 4) > 0 )
{
strcat(root,buffer);
}
getFiles(siz, root, infor);
sendto(sfd, result, 1024, 0, (struct sockaddr *) &cli, siz_cli);
close(fd);
}
}//while
close(sfd);
}//else
}
Thanks