Y
Yarco
when doing fork in a loop:
If there's no fork, the code done well.
But if fork, when telnet, it has error: accept: Invalid argument
Thanks a lot.
Code:
while(1) {
tmp_sd = accept(sd, (struct sockaddr*)&tmp_sin, &len);
if (tmp_sd == -1) {
perror("accept");
exit(0);
}
//check client ip
//fork
pid = fork();
switch(pid) {
case -1:
perror("fork");
break;
case 0:
_exit(0);
}
close(tmp_sd);
}
But if fork, when telnet, it has error: accept: Invalid argument
Thanks a lot.