winsock server 示例代码中 shutdown 的选项

When the server is done sending data to the client, the shutdown function can be called specifying SD_SEND to shutdown the sending side of the socket. This allows the client to release some of the resources for this socket. The server application can still receive data on the socket.

// shutdown the send half of the connection since no more data will be sent
iResult = shutdown(ClientSocket, SD_SEND);
if (iResult == SOCKET_ERROR) {
    printf("shutdown failed: %d
", WSAGetLastError());
    closesocket(ClientSocket);
    WSACleanup();
    return 1;
}

要全部关闭,应该用 SD_BOTH

原文地址:https://www.cnblogs.com/liujx2019/p/13680525.html