Closing/cleaning up “mixed” file descriptors / sockets
问题 When I create a socket using accept() and make a FILE out of it using fdopen(), what do I have to do to clean everything up? Do I need to do fclose() on the FILE, shutdown() and close() on the socket, or only the shutdown() and or close() or fclose()? If I don't do fclose(), do I have to free() the FILE pointer manually? 回答1: From man fdopen: The file descriptor is not dup’ed, and will be closed when the stream created by fdopen() is closed So I would just use fclose(), which also closes the