开发者

sending data packet just before closing socket

开发者 https://www.devze.com 2023-01-01 22:48 出处:网络
Before disconnect the client, the server wants to send some info to the client - why do I(server) disconnect you(client).

Before disconnect the client, the server wants to send some info to the client - why do I(server) disconnect you(client).

If I send packet to the info and close the client socket immediately, closesocket() returns -1 and if I use linger option to work closesocket() succe开发者_StackOverflow社区ssfully, the info cannot be sent completely.

How can I complete this and is it possible to know socket buffer is empty(means my packet sent all)?

thx.


try to call shutdown() on socket first.

http://msdn.microsoft.com/en-us/library/ms740481%28VS.85%29.aspx

http://www.opengroup.org/onlinepubs/000095399/functions/shutdown.html

0

精彩评论

暂无评论...
验证码 换一张
取 消