[code=txt] If the connection has been gracefully closed, the return value is zero.[/code]
...全文
6096打赏收藏
怎么才能优雅地关闭连接
看recv函数的返回值官方文档。提到了“优雅地关闭连接,就返回0“,但是我在客户端调closesocket,server端还是得到-1啊 [code=txt] If the connection has been gracefully closed, the return value is zero.[/code]
To assure that all data is sent and received on a connected socket before it is closed, an application should use shutdown to close connection before calling closesocket.