I am new to socket programming. Forgive me if the question doesn't make sense.

In my program below,I use fork() to create 3 child processes. In each child process I call the socket() to get a socket descriptor. I expect the system returns different value for the socket calls. But it doesn't; in every child process, sfd has the same value. What goes wrong?

#include stdio.h
#include sys/socket.h

int main()
{
int pid,ppid,sfd;
int i;

ppid=getpid();

for(i=0;i<3;i++)
{
if(getpid()==ppid)
{
if((pid=fork())==0)
{
sfd=socket(AF_INET,SOCK_STREAM,0);
printf("socketfd=%d\n",sfd);
}
}
}

return 0;
}

Thanks in advance!