1

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 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.