is it a socket or is it not?
Curtis Generous
generous at dgis.daitc.mil
Sun Jul 30 03:49:15 AEST 1989
What's a good method of determining whether a file descriptor
is a socket or not? The fstat(2) call does not work well on sockets
(and it even says so in the man page :-)
This is what I would like to do but doesn't work:
if (fstat(fildes, &statb) == 0) {
if ((statb.st_mode &= S_IFMT) == S_IFSOCK)
sockflag++;
}
Is there a better/cleaner way? Do you go through the list of possibles
and work by elimination (S_IFREG, S_IFDIR, ...)? Can I assume that fstat(2)
will _always_ return a zeroed buffer as mentioned in the BUGS of the man page?
The OS is More/BSD 4.3 on a VAX 780, but I think this spans many BSD derivatives
--curtis
--
Curtis C. Generous
DTIC Special Projects Office (DTIC-SPO)
ARPA: generous at daitc.mil
UUCP: {uunet,vrdxhq,lll-tis}!daitc!generous
More information about the Comp.unix.questions
mailing list