Re: socket closing

From: Glynn Clements (glynn.clements@virgin.net)
Date: Wed Apr 25 2001 - 21:27:01 EST


Lee Chin wrote:

> How do I tell if a file descriptor is a socket or not in C?

Use fstat(), e.g.

        struct stat st;
        if (fstat(fd, st) < 0) { perror("fstat"); exit(1); }
        if (S_ISSOCK(st.st_mode)) ...

-- 
Glynn Clements <glynn.clements@virgin.net>
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org



This archive was generated by hypermail 2b29 : Mon Apr 30 2001 - 21:00:29 EST