Shutdown prototypes
int shutdown (int socket, int how); socket specifies the socket's file descriptor how to specify the type of shutdown SHUT_RD
Prohibit read operation
SHUT_WR prohibit write operation Shut_rdwr Read and write Forbidden
Close prototypes
int close (int fd); Close is a kernel function that closes the file handle that the process occupies, each file handle in the kernel has a reference count, each process that opens the file handle counts +1, and each call to close will close the file descriptor that the process occupies, and the reference count in the kernel-1.
Difference
Shutdown directly on the socket connection, after calling shutdown, all file descriptors associated with the socket are affected (not readable or writable, or neither), that is, the impact is cross-process, shutdown does not close the socket, The socket is passively closed at the associated file descriptor kernel count of 0 o'clock.
Close works on the file descriptor of the process open, and after close the process will not be able to access the socket, the socket will turn off when the reference count becomes 0 o'clock, and if multiple processes access the file descriptor of the same socket, one of the processes calls close (SOCKFD Other processes can proceed with socket communication.
Shutdown and close of sockets