ok...i'll post the important parts...
Server main process...creating child process to deal with more than one client:
Code:
if (pid == 0) {
close(sockfd);
comunic(newsockfd); /
printf("closed client %s \n", inet_ntoa(cli_addr.sin_addr));
exit(0);
}
Function 'comunic': (only some parts...function is big)
Code:
...
char buffer[256];
char path[256];
memset(path,0,sizeof(path));
if(recv(sock,path,sizeof(path),0)<=0){
error("Error 'recv'. Connection lost");
}
memset(buffer,0,sizeof(buffer));
n = recv(sock,buffer,sizeof(buffer),0);
if (n < 0) {
error("Erro a receber mensagem no socket");
}
else if(n==0){
error("Houve um shutdown por parte do cliente. Falha na ligação");
}
else{
int aux,existe;
existe=file_exist(path,buffer);
if(existe==-1){
printf("opendir failed...path doesn't exist\n"); //
}
aux=htons(existe);
if(send(sock,&aux,sizeof(aux),0)<0){
error("Error send");
}
....
.....
...
.
.
the problem is that, this last send function, doesn't appear to be running...
i'm doing a recv on client side, so client can realize that he writted a bad directory...that the directory wasn't found....
and i'm doing a printf on client, to show this last info sent by server...but it doesn't show anything...it just ends right away
client recv:
Code:
if(recv(sockfd,&estado,sizeof(int),0)<0){
error("Error");
}
estado=ntohs(estado);
printf("%d \n",estado);