The Chrome Socket API allows us to disconnect() from a TCP socket. But how can I decide if I want the socket to stay half-open or not after the other side has sent a FIN packet? Thanks.
1 Answer
If you've received a FIN packet it already is half-open, at best. You can only send data from your end, not receive it, and you mightn't even be able to send if the peer has closed completely. You would have to try it. Note that the resulting error (connection reset by peer) may be delayed due to buffering.
2 Comments
fridojet
Thanks for your answer - Two questions concerning that: 1)
"you mightn't even be able to send if the peer has closed completely", how can I disconnect respectively close completely using the Chrome API? -- 2) What's the best way to find out if the socket is half-open? I don't always want to send witless messages to my peer, when I want to find out.user207421
1. Close the socket. 2. You can't: you have to try it. But there's something wrong if you don't know. Part of the application protocol should embody this matter.