1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#ifndef DEBUG
if(!(child_pid = fork())){
sleep(30);
close(server_sockfd);
#endif
// read what the client has to say
n=read(client_sockfd,&nick,sizeof(nick));
while((n = read(client_sockfd, &buf,sizeof(buf)+1))>0)
{
serv_proc((char *)buf, (char *)nick);
bzero(buf, strlen(buf));
}
//close the client
//close (client_sockfd);
printf("\nConnexion closed\n");
exit(0); //end of fork()
#ifndef DEBUG
}
#else
close(server_sockfd);
#endif
close(client_sockfd); //parent close the ending sock
} |
Partager