I am learning about socket programming and I know c-programming well.
For example, based on my c-programming knowledge, once something inside an else statement is proces
Fork is used to create a new process. In the old process it returns the new process's pid and in the new process it returns 0. Each line of the output was printed by a different process.
http://linux.die.net/man/2/fork
To help you understand: From the moment you call fork() one more process is executing the program you wrote. To let you make these two processes do different things, fork() returns different values in the original process and in the duplicate. As I wrote, the original process receives pid of the new process, which is very useful for further communication between the two processes.