views:

234

answers:

2

Possible Duplicate:
Is 0 or 1 valid return values for socket() function call

what is the range for FD(File Descriptor)?

For example :

int sockfd = socket(AF_INET, SOCK_STREAM, 0);

or

newsockfd = accept(sockfd, (struct sockaddr *) & cli_addr, (socklen_t *) & clilen);

what is the range sockfd , newsockfd ? Are these >=0 or >=1 ?

+6  A: 

By default, standard input is 0. However, there's nothing very special about that. Daemons close(0) all the time, leaving it available for open() or socket().

bmargulies
+2  A: 

A socket file descriptor is no different than any other file descriptor in Linux. File descriptors can be 0..N.

Richard Pennington
Thanks i need to know the rang >=0 or >=1 and know >=0
SjB