Hello, I am trying to write a socket program to allow a program on another
box to run ppp-on on this one without having to telnet into my linux box
running ip_masq. My program basically goes like this:
socket()
bind()
listen()
and then an accept() loop that first blocks until it gets a connection,
adn then runs this code:
if (!fork()) // what does this line mean? if(fork == 0)?
{
send(new_fd, "hello\n", 6, 0);
close(new_fd);
while(waitpid(-1,NULL,WNOHANG) > 0);
}
this came from a socket tutorial, my actual code is a little different
and includes a recv that prints the first thing it recieves and then
continues, and it also has some error checking that I left out. I dont
understand what this is doing. particularly how the fork() function works.
Could someone explain this?
Thanks,
Jeff