pipe() returns an array with two file descriptors. socket() returns a single file descriptor. When you say that stdin is 0, that means that it is file descriptor 0. All of the system calls in sector 2 of the manual deal with file descriptors.
If you do an fopen(), on the other hand, you do not get a file descriptor, you get a pointer to a FILE structure. To convert that into an fd, just use fileno().