Re: socket closing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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>
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux